Jenkins Maven project
Create a Maven project that builds a Docker image and then scans it for vulnerability and compliance issues.
Configuring Maven
Configure Maven.
- Go to the Jenkins top page.
- Click Manage Jenkins.
- Select Global Tool Configuration.
- Scroll down to the Maven section (Not Maven Configuration), and click Add Maven.
Setting up a Maven project for container images
Set up a Jenkins Maven project.
- Go to the Jenkins top page.
- Create a new project.
- ClickNew Item.
- InItemname, enter a name for your project.
- SelectMaven project.
- ClickOK.
- Add a build step.
- Scroll down to thePre stepssection.
- In theAdd pre-build stepdrop-down list, selectExecute shell.
- In theCommandtext box, enter the following:echo "Creating Dockerfile..." echo "FROM imiell/bad-dockerfile:latest" > Dockerfile echo 'docker build --no-cache -t test/test-image:0.1 .' > build_image.sh chmod +x build_image.sh echo "Creating POM file..." cat > pom.xml << EOF <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>groupId</groupId> <artifactId>artifactid</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>projectName</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> <artifactId>exec-maven-plugin</artifactId> <groupId>org.codehaus.mojo</groupId> <executions> <execution> <id>Build Image</id> <phase>generate-sources</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>build_image.sh</executable> </configuration> </execution> </executions> </plugin> </plugins> </build> </project> EOF
- Add a build step that scans the container image(s) for vulnerabilities.
- In theAdd build stepdrop-down list, selectScan Prisma Cloud Images.