使用jenkins,我能够为我的应用程序生成一个发布应用程序包,但我被困在下一步,这涉及到为我的应用程序生成一个签名的应用程序包,以便我可以在playstore上更新我的构建。那么,有没有插件或其他方式可以让我在jenkins上为我的应用程序生成签名的应用程序包呢?
发布于 2021-07-19 18:51:02
这可以通过以下方式完成:
从build.gradle中提取
apply plugin: 'com.android.application'
def myStoreFile = System.getenv('MY_STORE_FILE')
def myStorePassword = System.getenv('MY_STORE_PASSWORD')
def myKeyAlias = System.getenv('MY_KEY_ALIAS')
def myKeyPassword = System.getenv('MY_KEY_PASSWORD')
android {
...
signingConfigs {
release {
if (myStoreFile) {
storeFile rootProject.file(myStoreFile)
storePassword myStorePassword
keyAlias myKeyAlias
keyPassword myKeyPassword
}
}
}
buildTypes {
release {
...
if (myStoreFile && myStorePassword && myKeyAlias && myKeyPassword) {
signingConfig signingConfigs.release
}
}
}
...
}从Jenkinsfile中提取:
stage ('Build and Sign Android Bundle') {
...
steps {
// Signing parameters are configured in Jenkins (here we use secret file, secret text and username with password respectively)
// and are passed to the build.gradle file using the environment variables (MY_STORE_FILE, MY_KEY_ALIAS etc)
withCredentials([file(credentialsId: 'android-store-file', variable: 'MY_STORE_FILE'),
string(credentialsId: 'android-store-password', variable: 'MY_STORE_PASSWORD'),
usernamePassword(credentialsId: 'android-key', usernameVariable: 'MY_KEY_ALIAS', passwordVariable: 'MY_KEY_PASSWORD')]) {
dir ('android-app-root-directory') {
sh 'gradle clean bundleRelease'
}
}
}
}https://stackoverflow.com/questions/61093519
复制相似问题