Jenkins free style Job for maven project
构建过程
git change -> freestyle shell job -> git pull new code -> maven build -> docker build ->docker-compose up -d
代码连接 https://github.com/nhz94259/rainbow-oneInch-perday/blob/master/shell/freestyle_job_java.sh
jenkins job 配置
启动任务
运行结果
Started by user nahongze Running as SYSTEM Building remotely on node-133 in workspace /opt/cloudnet/workspace/-service [ssb-service] $ /bin/bash /tmp/jenkins3152636716449592611.sh /home/jdk1.8.0_201 [info] create docker-compose.yml /opt/cloudnet/workspace/ssb-service/ssb-service [info] update ssb-service code current code branch is :master Already on 'master' git pulling Already up-to-date. [info] docker build ssb-service image. [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for com..cloudnet:ssb-service:jar:dev [WARNING] 'dependencyManagement.dependencies.dependency.exclusions.exclusion.artifactId' for com.netflix.eureka:eureka-core:jar with value '*' does not match a valid id pattern. @ org.springframework.cloud:spring-cloud-netflix-dependencies:2.0.2.RELEASE, /root/.m2/repository/org/springframework/cloud/spring-cloud-netflix-dependencies/2.0.2.RELEASE/spring-cloud-netflix-dependencies-2.0.2.RELEASE.pom, line 251, column 19 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building ssb-service dev [INFO] ------------------------------------------------------------------------ Downloading: http://mvnrepo.****.com.cn:8081/nexus/content/repositories/snapshots/com//cloudnet/common-lib/1.0.0-SNAPSHOT/maven-metadata.xml Downloading: http://mvnrepo.****.com.cn:8081/nexus/content/groups/public/com//cloudnet/common-lib/1.0.0-SNAPSHOT/maven-metadata.xml 996/996 B 996/996 B 996/996 B Downloaded: http://mvnrepo..****..com.cn:8081/nexus/content/groups/public/com/****/cloudnet/common-lib/1.0.0-SNAPSHOT/maven-metadata.xml (996 B at 4.9 KB/sec) Downloaded: http://mvnrepo..****..com.cn:8081/nexus/content/repositories/snapshots/com/****/cloudnet/common-lib/1.0.0-SNAPSHOT/maven-metadata.xml (996 B at 4.7 KB/sec) [INFO] [INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ ssb-service --- [INFO] Deleting /opt/cloudnet/workspace/ssb-service/ssb-service/target [INFO] [INFO] --- jacoco-maven-plugin:0.7.8:prepare-agent (default) @ ssb-service --- [INFO] argLine set to -javaagent:/root/.m2/repository/org/jacoco/org.jacoco.agent/0.7.8/org.jacoco.agent-0.7.8-runtime.jar=destfile=/opt/cloudnet/workspace/ssb-service/ssb-service/target/jacoco.exec [INFO] [INFO] --- git-commit-id-plugin:2.1.13:revision (default) @ ssb-service --- [info] dotGitDirectory /opt/cloudnet/workspace/ssb-service/ssb-service/.git [info] git.build.user.name [info] git.build.user.email [info] Detected that running on CI enviroment, but using repository branch, no GIT_BRANCH detected. [info] git.branch master [info] --always = true [info] --dirty = -dirty [info] --abbrev = 7 [info] Tag refs [ [] ] [info] Created map: [ {} ] [info] HEAD is [ 1c6fe443bf935c4ca4d5ed6d47827e4711ff2e54 ] [info] Repo is in dirty state [ false ] [info] git.commit.id.describe 1c6fe44 [info] git.commit.id 1c6fe443bf935c4ca4d5ed6d47827e4711ff2e54 [info] git.commit.id.abbrev 1c6fe44 [info] git.dirty false [info] git.commit.user.name 纳洪泽 [info] git.commit.user.email nahongze@****.com.cn [info] git.commit.message.full Update pom.xml [info] git.commit.message.short Update pom.xml [info] git.commit.time 2020-03-08T19:39:11+0800 [info] git.remote.origin.url git@gitlab.****.com.cn:/1.0/1-service.git [info] git.tags [info] git.build.time 2020-03-08T22:01:28+0800 [info] git.commit.id.describe-short 1c6fe44 [info] found property git.tags [info] found property git.commit.id.abbrev [info] found property git.commit.user.email [info] found property git.commit.message.full [info] found property git.commit.id [info] found property git.commit.id.describe-short [info] found property git.commit.message.short [info] found property git.commit.user.name [info] found property git.build.user.name [info] found property git.commit.id.describe [info] found property git.build.user.email [info] found property git.branch [info] found property git.commit.time [info] found property git.dirty [info] found property git.build.time [info] found property git.remote.origin.url [info] Writing properties file to [ /opt/cloudnet/workspace/ssb-service/ssb-service/target/classes/git.properties ] (for module ssb-service )... [INFO] [INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ ssb-service --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 3 resources [INFO] [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ ssb-service --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 118 source files to /opt/cloudnet/workspace/ssb-service/ssb-service/target/classes [INFO] /opt/cloudnet/workspace/ssb-service/ssb-service/src/main/java/com/****/cloudnet/ssb/service/syncdata/impl/CmdbCommonServiceImpl.java: Some input files use unchecked or unsafe operations. [INFO] /opt/cloudnet/workspace/ssb-service/ssb-service/src/main/java/com/****/cloudnet/ssb/service/syncdata/impl/CmdbCommonServiceImpl.java: Recompile with -Xlint:unchecked for details. [INFO] [INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ ssb-service --- [INFO] Not copying test resources [INFO] [INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ ssb-service --- [INFO] Not compiling test sources [INFO] [INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ ssb-service --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ ssb-service --- [INFO] Building jar: /opt/cloudnet/workspace/ssb-service/ssb-service/target/ssb-service-dev.jar [INFO] [INFO] --- spring-boot-maven-plugin:2.0.2.RELEASE:repackage (default) @ ssb-service --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 12.930s [INFO] Finished at: Sun Mar 08 22:01:35 CST 2020 [INFO] Final Memory: 67M/571M [INFO] ------------------------------------------------------------------------ Sending build context to Docker daemon 78.01MB Step 1/9 : FROM registry.****.com.cn/****/jdk:8 ---> dfafda6d5b0d Step 2/9 : ARG name ---> Using cache ---> 15bebb48a7d0 Step 3/9 : ENV port 0 ---> Using cache ---> eadb9d4b476d Step 4/9 : ENV profile dev ---> Using cache ---> 7b17b84224da Step 5/9 : ENV eureka-server http://eureka:8080/eureka ---> Using cache ---> 9f08d76ad952 Step 6/9 : ENV app-secret ecudowid ---> Using cache ---> 6c4c40b0d6da Step 7/9 : COPY target/$name.jar app.jar ---> 66120c1c6ed6 Step 8/9 : EXPOSE $port ---> Running in 5e932f8ca949 Removing intermediate container 5e932f8ca949 ---> 6f78e425de14 Step 9/9 : ENTRYPOINT ["java", "-jar", "app.jar"] ---> Running in b665f67ea842 Removing intermediate container b665f67ea842 ---> 839b14dde404 Successfully built 839b14dde404 Successfully tagged registry.****.com.cn/.****./ssb-service:rc-2020.03.08.22.01.14 [info] create ssb-service container. Recreating ssb-service_ssb-service_1 ... [1B [info] images:tag=registry.****.com.cn/.****./ssb-service:rc-2020.03.08.22.01.14 Finished: SUCCESS
nhz94259@163.com