[英]Fail to sign Android APK from Jenkins, but works from command line
I've got the following build environment : 我有以下构建环境:
I can create a release APK (zipaligned and signed) from the command line (in the jenkins workspace area), by running ant release
and then typing in the keystore passes when prompted. 我可以从命令行(在jenkins工作区中)创建一个发布APK(zipaligned and signed),运行
ant release
,然后在提示时键入密钥库。
However using the same build command from a Jenkins job it fails with the following : 但是,如果使用Jenkins作业中的相同构建命令,则会失败并显示以下内容:
release:
[echo] Signing final apk...
[signjar] Signing JAR: /home/james/.jenkins/workspace/android-sam/androidsam/bin/AndroidSam-unsigned.apk to /home/james/.jenkins/workspace/android-sam/androidsam/bin/AndroidSam-unaligned.apk as mykeystore
[signjar] jarsigner: Certificate chain not found for: mykeystore . mykeystore must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.
BUILD FAILED
/home/james/tools/android-sdk-linux_x86/tools/ant/main_rules.xml:641: jarsigner returned: 1
In the jenkins ant target step, I've set the following properties : 在jenkins ant目标步骤中,我设置了以下属性:
key.store=my-release-key.keystore
key.alias=mykeystore
key.store.password=<mypass>
key.alias.password=<mypass>
sdk.dir=/home/james/tools/android-sdk-linux_x86
What would cause jenkins to fail to sign, whereby executing the same target from the command line works fine? 什么会导致jenkins无法签名,从命令行执行相同的目标工作正常?
I've googled for this, and have found some people are writing their own bash scripts to sign their APKs, and running these as shell targets afterwards, but it seems quite a dirty way...any suggestions? 我已经搜索了这个,并且发现有些人正在编写自己的bash脚本来签署他们的APK,然后将这些作为shell目标运行,但这似乎是一种肮脏的方式......任何建议?
Thanks 谢谢
We have set up our Jenkins server to sign our APKs using the same technique you outline here, and it works for us. 我们已经设置了我们的Jenkins服务器,使用您在此处概述的相同技术来签署我们的APK,它适用于我们。 One difference is that I put the fully-qualified path to the keystore rather than relying on a relative path.
一个区别是我将完全限定的路径放到密钥库而不是依赖于相对路径。 I'm never sure where they are relative from.
我不知道他们在哪里相对。 If your keystore is in version control, Jenkins provides a workspace root environment variable that you can use to point at it.
如果您的密钥库处于版本控制中,Jenkins提供了一个工作区根环境变量,您可以使用它来指向它。
It would also be worth testing this build from the command line where you define all those properties with ant -Dkey.store=/some/key.store ...
directives to make sure that all the values you've provided are correct. 从命令行测试此构建也是值得的,您可以使用
ant -Dkey.store=/some/key.store ...
指令定义所有这些属性,以确保您提供的所有值都正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.