Skip to content

Instantly share code, notes, and snippets.

@talalUcef
Last active September 12, 2019 08:57
Show Gist options
  • Save talalUcef/e15c55b6ec71226f9eafb372c593bce4 to your computer and use it in GitHub Desktop.
Save talalUcef/e15c55b6ec71226f9eafb372c593bce4 to your computer and use it in GitHub Desktop.
Integrate dependency-check-maven plugin with Jenkins
stage('Dependency Check') {
steps {
echo 'Running dependency check'
withMaven(maven: 'maven 3.6.0', globalMavenSettingsConfig: 'sfcoGlobalSettingsV1', mavenSettingsConfig: 'sfcoSettingsV1') {
sh 'mvn -Dmaven.test.skip=true package -Psecurity'
}
}
post {
always {
dependencyCheckPublisher pattern: "**/dependency-check-report.xml"
}
}
}
<properties>
<dependency-check-format>ALL</dependency-check-format>
<owasp-maven-plugin.version>5.2.1</owasp-maven-plugin.version>
</properties>
<profile>
<id>security</id>
<build>
<plugins>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>${owasp-maven-plugin.version}</version>
<configuration>
<!-- Skip artifacts not bundled in distribution (provided scope) -->
<skipProvidedScope>true</skipProvidedScope>
<!-- Suppress false positives or dependencies that cannot be changed for specific reasons.-->
<!--<suppressionFile>suppressed-cves.xml</suppressionFile>-->
<format>${dependency-check-format}</format>
<outputDirectory>${project.basedir}/target/reports</outputDirectory>
</configuration>
<!-- Don't specify an execution, because this might take long and is not needed in every build.
A report can be generated on demand using "mvn org.owasp:dependency-check-maven:check"
report will be saved to target/dependency-check-report.html -->
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment