The lightest configuration of Jenkins + docker + dockerfile Maven plugin + harbor CI / CD spring boot project


This paper is only for future reference, recording some key steps and stepping on the pit

Dockerfile Maven plugin building image configuration

Parameter description
${docker.repository} image warehouse address
${docker.image.prefix} image library prefix / distinguished item classification
${project.artifactId} package Id / unique image name
1  <properties>
2         <java.version>8</java.version>
3         <docker.image.prefix>yourprefix</docker.image.prefix>
4         <docker.repository>yourrepositoryurl</docker.repository>
5     </properties>
Image warehouse configuration


maven configuration in jenkins setting.xml - set the address and account password to log in to harbor

You need to push the image in the previous step

File location: / var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/mvn3.6.3/conf

New Server node


dockerfile configuration

FROM openjdk:8u181-jdk-alpine
ARG workdir=/app
VOLUME ${workdir}
WORKDIR ${workdir}
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","","-jar","app.jar"]

System settings - global tool configuration jdk maven






jenkins creates a new job and builds it with maven

Connect git



Plug in version number generates build version number




Execute maven build command

clean package -Dmaven.test.skip=true -P dev


Use the version number tag to create a new image and push it to harbor

Execute the script to push the image to the private registry and report the error without permission





Solution: login private registry is required (execute login command in Jenkins container)

After successful execution, the config.json file will be generated in the root/.docker folder (with the credentials of login private registry)


ssh specifies the server to pull the image and run - plug in Publish Over SSH


Keywords: Java Docker Maven jenkins

Added by matthewc on Fri, 20 Dec 2019 16:06:33 +0200