Maven Shade插件:仅创建快照,不发布

时间:2019-07-15 08:56:57

标签: maven apache-flink nexus maven-shade-plugin

我们正在使用Apache Flink,根据其documentation,它需要Maven Shade插件来构建包含所有依赖项的应用程序JAR。

我习惯于使用Maven Release插件,似乎表明Shade插件完成了类似的工作,除了捆绑和重命名(也称为“阴影”)依赖项。

我们有一个Jenkins管道作业,可以在“ master”分支上进行以下调用:

mvn -B -Dmaven.test.failure.ignore=true -Dmaven.test.skip=true -DskipTests release:prepare release:perform -e

我期望的是以下内容(可能不是按此顺序):

  • 已构建新的SNAPSHOT版本并将其上传到Nexus
  • 已构建新的RELEASE版本并将其上传到Nexus
  • 该分支被标记为应用名称和发布号
  • 使用新的快照编号更新POM
  • POM已签入Git

实际发生的事情:

  • 创建并标记了一个“本地”分支(即,对于Jenkins实例而言是本地的)
  • 已构建新的SNAPSHOT版本并将其上传到Nexus

Jenkins日志,并包含相关的构建信息(并删除了不相关的部分):

Checking out git ..[COMPANY]/[PROJECT].git into /var/jenkins_home/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]@script to read Jenkinsfile.groovy
.... 
[[PROJECT]] Running shell script
...
[Pipeline] sh
[[PROJECT]] Running shell script
+ mvn -B -Dmaven.test.failure.ignore=true -Dmaven.test.skip=true -DskipTests release:prepare -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building [PROJECT]-job 0.0.13-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-release-plugin:2.3.2:prepare (default-cli) @ [PROJECT]-job ---
[INFO] Verifying that there are no local modifications...
[INFO]   ignoring changes on: **/pom.xml.releaseBackup, **/pom.xml.next, **/pom.xml.tag, **/pom.xml.branch, **/release.properties, **/pom.xml.backup
[INFO] Executing: /bin/sh -c cd "/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]" && git status
[INFO] Working directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]
[INFO] Checking dependencies and plugins for snapshots ...
[INFO] Transforming '[PROJECT]-job'...
[INFO] Not generating release POMs
[INFO] Executing goals 'clean verify'...
[INFO] [INFO] Scanning for projects...
[INFO] [INFO] 
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building [PROJECT]-job 0.0.13
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] 
[INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ [PROJECT]-job ---
[INFO] [INFO] 
[INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ [PROJECT]-job ---
[INFO] [INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] [INFO] Copying 2 resources
[INFO] [INFO] 
[INFO] [INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ [PROJECT]-job ---
[INFO] [INFO] Changes detected - recompiling the module!
[INFO] [INFO] Compiling 15 source files to /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/classes
[INFO] [INFO] /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/src/main/java/[SUB_PROJECT]/jobs/[MAIN_CLASS]].java: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/src/main/java/[SUB_PROJECT]/jobs/[MAIN_CLASS]].java uses or overrides a deprecated API.
[INFO] [INFO] /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/src/main/java/[SUB_PROJECT]/jobs/[MAIN_CLASS]].java: Recompile with -Xlint:deprecation for details.
[INFO] [INFO] /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/src/main/java/[SUB_PROJECT]/serialisers/CustomDateSerializer.java: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/src/main/java/[SUB_PROJECT]/serialisers/CustomDateSerializer.java uses unchecked or unsafe operations.
[INFO] [INFO] /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/src/main/java/[SUB_PROJECT]/serialisers/CustomDateSerializer.java: Recompile with -Xlint:unchecked for details.
[INFO] [INFO] 
[INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ [PROJECT]-job ---
[INFO] [INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] [INFO] skip non existing resourceDirectory /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/src/test/resources
[INFO] [INFO] 
[INFO] [INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ [PROJECT]-job ---
[INFO] [INFO] Changes detected - recompiling the module!
[INFO] [INFO] Compiling 9 source files to /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/test-classes
[INFO] [INFO] 
[INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ [PROJECT]-job ---
[INFO] [INFO] Surefire report directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/surefire-reports
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
...
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 43.627 s
[INFO] [INFO] Finished at: 2019-07-10T09:55:32Z
[INFO] [INFO] Final Memory: 74M/638M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd "/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]" && git add -- pom.xml
[INFO] Working directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]
[INFO] Executing: /bin/sh -c cd "/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]" && git status
[INFO] Working directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]
[INFO] Tagging release with the label [PROJECT]-job-0.0.13...
[INFO] Executing: /bin/sh -c cd "/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]" && git tag -F /tmp/maven-scm-2648.commit [PROJECT]-job-0.0.13
[INFO] Working directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]
[INFO] Executing: /bin/sh -c cd "/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]" && git push ssh://bit... [PROJECT]-job-0.0.13
[INFO] Working directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]
[INFO] Executing: /bin/sh -c cd "/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]" && git ls-files
[INFO] Working directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]
[INFO] Transforming '[PROJECT]-job'...
[INFO] Not removing release POMs
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd "/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]" && git add -- pom.xml
[INFO] Working directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]
[INFO] Executing: /bin/sh -c cd "/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]" && git status
[INFO] Working directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]
[INFO] Release preparation complete.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
...
[Pipeline] sh
[[PROJECT]] Running shell script
+ git status
HEAD detached at 1033ff8
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
    modified:   pom.xml
+ mvn -B -Dmaven.test.failure.ignore=true -Dmaven.test.skip=true -DskipTests release:perform -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building [PROJECT]-job 0.0.14-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-release-plugin:2.3.2:perform (default-cli) @ [PROJECT]-job ---
[INFO] Checking out the project to perform the release ...
[INFO] Executing: /bin/sh -c cd "/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target" && git clone --branch [PROJECT]-job-0.0.13 ssh://git@bitbucket.. '/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout'
[INFO] Working directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target
[INFO] Executing: /bin/sh -c cd /tmp && git ls-remote ssh://git@bitbucket...
[INFO] Working directory: /tmp
[INFO] Executing: /bin/sh -c cd "/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout" && git fetch ssh://git@bitbucket...
[INFO] Working directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout
[INFO] Executing: /bin/sh -c cd "/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout" && git checkout [PROJECT]-job-0.0.13
[INFO] Working directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout
[INFO] Executing: /bin/sh -c cd "/home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout" && git ls-files
[INFO] Working directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout
[INFO] Invoking perform goals in directory /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout
[INFO] Executing goals 'deploy'...
[INFO] [INFO] Scanning for projects...
...
[INFO] [INFO] 
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building [PROJECT]-job 0.0.13-SNAPSHOT
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] 
[INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ [PROJECT]-job ---
[INFO] [INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] [INFO] Copying 2 resources
[INFO] [INFO] 
[INFO] [INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ [PROJECT]-job ---
[INFO] [INFO] Changes detected - recompiling the module!
[INFO] [INFO] Compiling 15 source files to /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/target/classes
[INFO] [INFO] /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/src/main/java/[SUB_PROJECT]/jobs/[MAIN_CLASS]].java: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/src/main/java/[SUB_PROJECT]/jobs/[MAIN_CLASS]].java uses or overrides a deprecated API.
[INFO] [INFO] /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/src/main/java/[SUB_PROJECT]/jobs/[MAIN_CLASS]].java: Recompile with -Xlint:deprecation for details.
[INFO] [INFO] /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/src/main/java/[SUB_PROJECT]/serialisers/CustomDateSerializer.java: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/src/main/java/[SUB_PROJECT]/serialisers/CustomDateSerializer.java uses unchecked or unsafe operations.
[INFO] [INFO] /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/src/main/java/[SUB_PROJECT]/serialisers/CustomDateSerializer.java: Recompile with -Xlint:unchecked for details.
[INFO] [INFO] 
[INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ [PROJECT]-job ---
[INFO] [INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] [INFO] skip non existing resourceDirectory /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/src/test/resources
[INFO] [INFO] 
[INFO] [INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ [PROJECT]-job ---
[INFO] [INFO] Changes detected - recompiling the module!
[INFO] [INFO] Compiling 9 source files to /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/target/test-classes
[INFO] [INFO] 
[INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ [PROJECT]-job ---
[INFO] [INFO] Surefire report directory: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/target/surefire-reports
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running [SUB_PROJECT].utils.EnvUtilsTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec
[INFO] Running [SUB_PROJECT].utils.SqlUtilsTest
[INFO] 09:56:25,764 INFO  [SUB_PROJECT].models.QosHeartbeatSerializationSchema                - ------------------initMapper-----------------
[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.513 sec
[INFO] 
[INFO] Results :
[INFO] 
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] [INFO] 
[INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ [PROJECT]-job ---
[INFO] [INFO] Building jar: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/target/[PROJECT]-job-0.0.13-SNAPSHOT.jar
[INFO] [INFO] 
[INFO] [INFO] >>> maven-source-plugin:3.1.0:jar (attach-sources) > generate-sources @ [PROJECT]-job >>>
[INFO] [INFO] 
[INFO] [INFO] <<< maven-source-plugin:3.1.0:jar (attach-sources) < generate-sources @ [PROJECT]-job <<<
[INFO] [INFO] 
[INFO] [INFO] 
[INFO] [INFO] --- maven-source-plugin:3.1.0:jar (attach-sources) @ [PROJECT]-job ---
[INFO] [INFO] Building jar: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/target/[PROJECT]-job-0.0.13-SNAPSHOT-sources.jar
[INFO] [INFO] 
[INFO] [INFO] --- maven-javadoc-plugin:3.1.1:jar (attach-javadocs) @ [PROJECT]-job ---
[INFO] [INFO] 
...
[INFO] [INFO] --- maven-shade-plugin:3.1.1:shade (default) @ [PROJECT]-job ---
[INFO] [INFO] Including ....
...
[INFO] [INFO] Replacing original artifact with shaded artifact.
[INFO] [INFO] Replacing /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/target/[PROJECT]-job-0.0.13-SNAPSHOT.jar with /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/target/[PROJECT]-job-0.0.13-SNAPSHOT-shaded.jar
[INFO] [INFO] Dependency-reduced POM written at: /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/dependency-reduced-pom.xml
[INFO] [INFO] 
[INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ [PROJECT]-job ---
[INFO] [INFO] Installing /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/target/[PROJECT]-job-0.0.13-SNAPSHOT.jar to /root/.m2/repository/com/[COMPANY]/cv/[PROJECT]-job/0.0.13-SNAPSHOT/[PROJECT]-job-0.0.13-SNAPSHOT.jar
[INFO] [INFO] Installing /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/dependency-reduced-pom.xml to /root/.m2/repository/com/[COMPANY]/cv/[PROJECT]-job/0.0.13-SNAPSHOT/[PROJECT]-job-0.0.13-SNAPSHOT.pom
[INFO] [INFO] Installing /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/target/[PROJECT]-job-0.0.13-SNAPSHOT-sources.jar to /root/.m2/repository/com/[COMPANY]/cv/[PROJECT]-job/0.0.13-SNAPSHOT/[PROJECT]-job-0.0.13-SNAPSHOT-sources.jar
[INFO] [INFO] Installing /home/jenkins/workspace/[TEAM_NAME]/Flink Jobs/[PROJECT]/target/checkout/target/[PROJECT]-job-0.0.13-SNAPSHOT-javadoc.jar to /root/.m2/repository/com/[COMPANY]/cv/[PROJECT]-job/0.0.13-SNAPSHOT/[PROJECT]-job-0.0.13-SNAPSHOT-javadoc.jar
[INFO] [INFO] 
[INFO] [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ [PROJECT]-job ---
[INFO] [INFO] Downloading from nexus: 
... {download files from nexus here}
[INFO] [INFO] Uploading to nexus: 
... {upload files from nexus here}
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 48.330 s
[INFO] [INFO] Finished at: 2019-07-10T09:56:52Z
[INFO] [INFO] Final Memory: 78M/661M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Cleaning up after release...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:12 min
[INFO] Finished at: 2019-07-10T09:56:52Z
[INFO] Final Memory: 12M/241M
[INFO] ------------------------------------------------------------------------

0 个答案:

没有答案