1,需要在jenkins中安装 android sign plugin,安装后可以在可使用的TAB中找到。
2.需要把签名用的jks文件转换成pkcs12,通过keytool,如果没有的话,可以先安装,转换命令如下
[email protected]:/home/XXXX# keytool -importkeystore -srckeystore sign-key.jks -srcstoretype JKS -deststoretype PKCS12 -destkeystore keystore.p12
Importing keystore sign-key.jks to keystore.p12...
Enter destination keystore password:
Re-enter new password:
Enter source keystore password:
Entry for alias devops-alias successfully imported.
Import command completed: 1 entries successfully imported, 0 entries failed or cancelled
3.需要把上边生成的keystore.p12文件上传到Jenkins的Credential里,生成认证书
4.在pipeline中,使用下面的方法进行签名
signAndroidApks (
keyStoreId: "xxxx-xxx-xxx-xxx-xxx",
keyAlias: "${Name}",
apksToSign: "app.apk",
skipZipalign: true
)
通过上面的命令生成一个app-signed.apk的签名后的文件,这个就是签名后的文件了
详细参见:
https://github.com/jenkinsci/android-signing-plugin