MavenShade插件:只创建快照,不发布

gab6jxml  于 2021-06-24  发布在  Flink
关注(0)|答案(0)|浏览(258)

我们使用的是apache flink,根据它的文档,它需要maven shade插件来构建包含所有依赖项的应用程序jar。
我习惯于使用maven发布插件,看起来shade插件做了类似的工作,除了绑定和重命名(aka“shading”)依赖项。
我们有一个jenkins管道作业,对“主”分支进行以下调用:

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

我希望从中得到以下信息(可能不是按此顺序排列):
一个新的快照版本被构建并上传到nexus
一个新的发布版本被构建并上传到nexus
分支被标记为应用程序名称和版本号
pom将更新为新的快照编号
pom已签入git
实际发生的情况:
创建并标记“local”分支(即jenkins示例的本地分支)
一个新的快照版本被构建并上传到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] ------------------------------------------------------------------------

更新:解决方案是在pom中使用显式版本maven release plugin(2.4.2)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题