简体   繁体   English

无法从Jenkins签署Android APK,但可以从命令行工作

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

I've got the following build environment : 我有以下构建环境:

  • Ubuntu Ubuntu的
  • Java 1.6.0_24 Java 1.6.0_24
  • Apache ant 1.8.2 Apache ant 1.8.2
  • Jenkins 1.427 詹金斯1.427
  • Jetty 6.1.26 码头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. 我可以从命令行(在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.

相关问题 如何从命令行构建android apk? - How to build android apk from command line? 签名apk适用于Android Studio,但为什么同一个密钥库在命令行上不起作用? - Signing apk works from Android Studio but why the same keystore do not work on command line? 从命令行签署 Android App Bundle - Sign Android App Bundle from Command Line android lanuch从命令行未知的apk应用程序 - android lanuch unknown apk applications from command line 无法从Unity命令行生成Android APK - Can't generate Android APK from Unity command line 从命令行在 Android 模拟器上安装和运行 .apk - Install and Run .apk on Android Emulator from Command Line 如何从 Linux 命令行在 Genymotion 模拟器上调试 Android APK? - How to debug an Android APK on a Genymotion emulator from a Linux command line? 分别对apk进行签名(eclipse或命令行)-(不直接来自eclipse项目) - sign apk separately (either eclipse or command line) - (not directly from eclipse project) 如何从Appcenter命令行和Jenkins将IPA和APK文件推送到App Center分发 - How to push IPA and APK file to App Center Distribute from appcenter command line and Jenkins Android系统。 如何从命令行启动模拟器,部署apk并运行apk? - Android. How from command line start emulator, deploy apk AND run apk?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM