[英]maven-jarsigner-plugin fails during Jenkins build but not on command line
Following environment given: 给出以下环境:
When building the maven project everything works fine and the assembly is built (with the assembly plugin as well as with the shade plugin) and finally the assembly is signed and verified with the maven-jarsigner-plugin. 在构建Maven项目时,一切工作正常,并且构建了程序集(使用程序集插件以及shade插件),最后使用maven-jarsigner-plugin对程序集进行了签名和验证。
BUT the same project configured in Jenkins fails during build when jarsigner is trying to sign the assembly. 但是 ,在jarsigner尝试对程序集进行签名时,在构建过程中在Jenkins中配置的同一项目将失败。 Log File says:
日志文件说:
message : Failed to execute goal org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign (sign) on project ext.pdfgui: Execution of 'cmd.exe /X /C ""C:\Program Files\Java\jdk1.6.0_43\jre\..\bin\jarsigner.exe" -verbose -keystore src/main/resources/signjar.keystore -storepass '*****' -keypass '*****' "D:\server\jenkinsWorkingDir\jobs\<project name>\workspace\trunk\<module>\target\artifact-jar-with-dependencies.jar" <cert alias>"' failed - Errorcode (1)
cause : Execution of 'cmd.exe /X /C ""C:\Program Files\Java\jdk1.6.0_43\jre\..\bin\jarsigner.exe" -verbose -keystore src/main/resources/signjar.keystore -storepass '*****' -keypass '*****' "D:\server\jenkinsWorkingDir\jobs\<project name>\workspace\trunk\<module>\target\artifact-jar-with-dependencies.jar" <cert alias>"' failed - Errorcode (1)
Stack trace :
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign (sign) on project ext.pdfgui: Execution of 'cmd.exe /X /C ""C:\Program Files\Java\jdk1.6.0_43\jre\..\bin\jarsigner.exe" -verbose -keystore src/main/resources/signjar.keystore -storepass '*****' -keypass '*****' "D:\server\jenkinsWorkingDir\jobs\<project name>\workspace\trunk\<module>\target\artifact-jar-with-dependencies.jar" <cert alias>"' failed - Errorcode (1)
I translated log file above from German to English so it might differ because I dont know exactly the right wording. 我将上面的日志文件从德语翻译成英语,因此可能会有所不同,因为我不知道确切的用词。
Verbose log file says: 详细的日志文件说:
[INFO] jarsigner: attempt to rename D:\server\jenkinsWorkingDir\jobs\<project name>\workspace\trunk\<module>\target\<artifact>-jar-with-dependencies.jar to D:\server\jenkinsWorkingDir\jobs\<project name>\workspace\trunk\<module>\target\<artifact>-jar-with-dependencies.jar.orig failed
Looking for a solution brought me to this blog entry: http://www.iliachemodanov.ru/en/blog-en/14-tools/maven/44-maven-assembly-plugin-bug-en 寻找解决方案使我进入了此博客条目: http : //www.iliachemodanov.ru/zh_CN/blog-en/14-tools/maven/44-maven-assembly-plugin-bug-en
Here the "maven-shade-plugin" was mentioned as a solution, so I give it a try. 这里提到了“ maven-shade-plugin”作为解决方案,因此我尝试一下。 Reconfigured pom file but with the same effect.
重新配置了pom文件,但效果相同。 It seams that Windows or Tomcat or Jenkins keeps a file handle on the assembly and the jarsigner plugin is not able to rename it.
它表明Windows或Tomcat或Jenkins在程序集中保留了文件句柄,而jarsigner插件无法重命名它。
So my answer for a possible solution. 所以我的答案是可能的解决方案。 Any other more sophisticated solutions appreciated.
任何其他更复杂的解决方案表示赞赏。
And here is how I solved it currently: I moved the asssembly/shade plugin (it doesn't matter which you use, its in your favour) to a maven profile called "assembly" which is active by default. 这是我当前解决问题的方式:我将组装/阴影插件(无论您使用哪种插件,对您有利)都移动到了一个名为“ assembly”的Maven配置文件,该配置文件默认情况下处于活动状态。
Then I moved the jarsigner plugin also to another plugin called "jarsigner" and also active by default. 然后,我将jarsigner插件也移到了另一个名为“ jarsigner”的插件,默认情况下也处于活动状态。
So nothing changes when project is build from command line. 因此,从命令行构建项目时,没有任何变化。
Then I configured Jenkins in first building the project with assmebly plugin activated and jarsigner plugin deactivated by calling 然后,我在配置Jenkins的过程中首先通过激活assmebly插件和取消调用jarsigner插件来构建项目
-Passembly,!jarsigner
And configured a post build step just calling following goals and arguments 并配置了一个构建后步骤,仅调用以下目标和参数
deploy -P!assembly,jarsigner -DskipTests
Skipping tests here for performance because they should already passed during "normal" build and need not to be executed twice. 此处跳过性能测试,是因为它们应该在“正常”构建期间通过并且不需要执行两次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.