无法从 Jenkins 签署 Android APK,但可以从命令行运行
我有以下构建环境:
- Ubuntu
- Java 1.6.0_24
- Apache ant 1.8.2
- Jenkins 1.427
- Jetty 6.1.26
我可以通过运行从命令行(在 jenkins 工作区区域)创建一个发布 APK(zipaligned 和signed) ant release
,然后在出现提示时输入密钥库通行证。
但是,使用 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
在 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
什么会导致 jenkins 无法签名,从而从命令行执行相同的目标有效美好的?
我用谷歌搜索了这个,发现有些人正在编写自己的 bash 脚本来签署他们的 APK,然后将它们作为 shell 目标运行,但这似乎是一种很肮脏的方式......有什么建议吗?
谢谢
I've got the following build environment :
- Ubuntu
- Java 1.6.0_24
- Apache ant 1.8.2
- Jenkins 1.427
- Jetty 6.1.26
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.
However using the same build command from a Jenkins job it fails with the following :
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 :
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?
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?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们已经设置了 Jenkins 服务器,使用您在此处概述的相同技术来签署我们的 APK,并且它对我们有用。一个区别是我将完全限定的路径放在密钥库中,而不是依赖相对路径。我一直不确定他们是哪里的亲戚。如果您的密钥库处于版本控制中,Jenkins 会提供一个工作区根环境变量,您可以使用它来指向它。
还值得从命令行测试此构建,在命令行中使用 ant -Dkey.store=/some/key.store ... 指令定义所有这些属性,以确保您的所有值所提供的都是正确的。
We have set up our Jenkins server to sign our APKs using the same technique you outline here, and it works for us. 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.
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.