67 lines
2.2 KiB
Groovy
67 lines
2.2 KiB
Groovy
pipeline {
|
|
agent { label 'android' }
|
|
|
|
environment {
|
|
ANDROID_HOME = '/opt/android-sdk'
|
|
ANDROID_SDK_ROOT = '/opt/android-sdk'
|
|
JAVA_HOME = '/opt/java/openjdk'
|
|
PATH = "${env.ANDROID_HOME}/cmdline-tools/latest/bin:${env.ANDROID_HOME}/platform-tools:${env.PATH}"
|
|
}
|
|
|
|
options {
|
|
buildDiscarder(logRotator(numToKeepStr: '10'))
|
|
timeout(time: 30, unit: 'MINUTES')
|
|
}
|
|
|
|
stages {
|
|
stage('Build Debug APK') {
|
|
steps {
|
|
sh 'chmod +x gradlew'
|
|
sh './gradlew assembleDebug --no-daemon'
|
|
}
|
|
}
|
|
|
|
stage('Build Release APK') {
|
|
when {
|
|
expression {
|
|
try {
|
|
withCredentials([file(credentialsId: 'joykoo-scanner-keystore', variable: 'TEST')]) {}
|
|
return true
|
|
} catch (e) {
|
|
echo 'Signing credentials not configured — skipping release build.'
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
steps {
|
|
withCredentials([
|
|
file(credentialsId: 'joykoo-scanner-keystore', variable: 'KEYSTORE_FILE'),
|
|
usernamePassword(credentialsId: 'joykoo-scanner-keystore-creds',
|
|
usernameVariable: 'KEY_ALIAS',
|
|
passwordVariable: 'KEY_PASSWORD')
|
|
]) {
|
|
sh '''
|
|
./gradlew assembleRelease --no-daemon \
|
|
-Pandroid.injected.signing.store.file=$KEYSTORE_FILE \
|
|
-Pandroid.injected.signing.store.password=$KEY_PASSWORD \
|
|
-Pandroid.injected.signing.key.alias=$KEY_ALIAS \
|
|
-Pandroid.injected.signing.key.password=$KEY_PASSWORD
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
success {
|
|
archiveArtifacts artifacts: 'app/build/outputs/apk/**/*.apk', fingerprint: true
|
|
}
|
|
failure {
|
|
echo 'Build failed — check the console output above.'
|
|
}
|
|
always {
|
|
cleanWs()
|
|
}
|
|
}
|
|
}
|