开发者

Fail to sign Android APK from Jenkins, but works from command line

开发者 https://www.devze.com 2023-04-04 01:38 出处:网络
I\'ve got the following build environment : Ubu开发者_StackOverflowntu Java 1.6.0_24 Apache ant 1.8.2

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.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号