Skip to content

Instantly share code, notes, and snippets.

@AlexGladkov
Created February 21, 2025 14:26
Show Gist options
  • Save AlexGladkov/601b9b35676bd2d43f32a0be41402cea to your computer and use it in GitHub Desktop.
Save AlexGladkov/601b9b35676bd2d43f32a0be41402cea to your computer and use it in GitHub Desktop.
jenkins Build [Linux]
pipeline {
agent any
environment {
ANDROID_HOME = "/opt/android-sdk"
PATH = "$PATH:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools"
COMPANY_A_BASE_URL = credentials("company-a-base-url")
COMPANY_A_API_KEY = credentials("company-a-api-key")
COMPANY_B_BASE_URL = credentials("company-b-base-url")
COMPANY_B_API_KEY = credentials("company-b-api-key")
KEYSTORE_PASSWORD = credentials("keystore-password")
KEY_ALIAS_PASSWORD = credentials("key-alias-password")
ALIAS = "key-test"
}
parameters {
choice(name: 'FLAVOUR', choices: ['companyA', 'companyB'], description: "Выберите flavour для сборки")
}
stages {
stage('Checkout') {
steps {
script {
node {
git branch: 'pre-jenkins', url: 'https://github.com/AlexGladkov/maw_chapter3_block5_demo1.git'
}
}
}
}
stage('Setup') {
steps {
script {
node {
withCredentials([file(credentialsId: 'my-keystore-file', variable: 'KEYSTORE_FILE')]) {
sh '''
echo "KEYSTORE_FILE=${KEYSTORE_FILE}"
if [ -f "${KEYSTORE_FILE}" ]; then
echo "Файл загружен корректно"
else
echo "ФАЙЛ НЕ ЗАГРУЗИЛСЯ!"
fi
'''
}
}
}
}
}
stage('Build') {
steps {
script {
node {
def flavour = params.FLAVOUR
sh 'printenv'
sh "./gradlew clean bundle${flavour}FreeRelease --build-cache"
}
}
}
}
stage('Upload to Google Play') {
steps {
script {
node {
def aabPath = "app/build/outputs/bundle/${params.FLAVOUR}FreeRelease/app-${params.FLAVOUR}-free-release.aab"
sh "echo $aabPath"
sh "mkdir -p /var/lib/jenkins/Builds"
sh "cp $aabPath /var/lib/jenkins/Builds/"
}
}
}
}
}
post {
always {
script {
node {
sh 'rm -f my-keystore.jks'
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment