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.
  1. Go to the Jenkins top page.
  2. Click Manage Jenkins.
  3. Select Global Tool Configuration.
  4. 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.
  1. Go to the Jenkins top page.
  2. Create a new project.
    1. Click
      New Item
      .
    2. In
      Item
      name, enter a name for your project.
    3. Select
      Maven project
      .
    4. Click
      OK
      .
  3. Add a build step.
    1. Scroll down to the
      Pre steps
      section.
    2. In the
      Add pre-build step
      drop-down list, select
      Execute shell
      .
    3. In the
      Command
      text 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
  4. Add a build step that scans the container image(s) for vulnerabilities.
    1. In the
      Add build step
      drop-down list, select
      Scan Prisma Cloud Images
      .
      </