简体   繁体   English

在Jenkins构建过程中,maven-jarsigner-plugin失败,但在命令行上却没有

[英]maven-jarsigner-plugin fails during Jenkins build but not on command line

Following environment given: 给出以下环境:

  • Windows Server 2012 Windows Server 2012
  • Java 1.6 Java 1.6
  • Maven project with configured (assembly or shade plugin) AND jarsigner:sign/verify plugin Maven项目配置(组装或阴影插件)和jarsigner:sign / verify插件
  • Jenkins 1.518 running within Tomcat 7 (which runs with Java 1.7) 在Tomcat 7(与Java 1.7一起运行)中运行的Jenkins 1.518
  • Tomcat running as Windows Service User 以Windows服务用户身份运行的Tomcat

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.

相关问题 如何仅在Maven-jarsigner-plugin中的发行版上配置TSA参数 - How to configure TSA argument only on release in maven-jarsigner-plugin Maven jarsigner插件在发布期间不起作用 - Maven jarsigner plugin does not work during release maven-jarsigner在构建期间不执行 - maven-jarsigner not executing during build Maven构建在IntelliJ内部和命令行上失败 - Maven build fails inside IntelliJ and on command line Maven 构建无法在 jenkins websphere 部署插件中部署 - Maven build fails to deploy in jenkins websphere deployment plugin Maven jarsigner插件配置不起作用 - Maven jarsigner plugin configuration not working Wsimport 在 Maven 构建期间失败 - Wsimport fails during Maven build Cobertura Maven插件在Windows上因“命令行太长”而失败 - Cobertura Maven Plugin fails with “The command line is too long” on Windows 无法获取org.jacoco.maven.AgentMojo的Class-Jenkins无法使用JaCoCo maven插件进行构建,但可以在本地使用 - Failed to getClass for org.jacoco.maven.AgentMojo - Jenkins fails to build with JaCoCo maven plugin but works locally webstart-maven-plugin jarsigner因SHA1签名文件摘要无效而失败 - webstart-maven-plugin jarsigner fails with invalid SHA1 signature file digest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM