pipeline { agent { node { label 'MachineSlave1' } } environment { SUCCESS = 'true' STAGE = 'none' IMAGE_DOCKER = 'registry.vodorod.cl/deal/tienda-playa-servicio:latest' } stages { stage('Quarkus Compile') { steps { sh 'chmod +x mvnw && ./mvnw package -Dquarkus.package.type=uber-jar -Dquarkus.profile=prod' } post { success { script { SUCCESS = 'true' STAGE = 'Quarkus Compile' } } failure { script { SUCCESS = 'false' STAGE = 'Quarkus Compile' } } aborted { script { SUCCESS = 'false' STAGE = 'Quarkus Compile' } } } } stage('Docker Build') { when { equals expected: 'true', actual: SUCCESS } steps { sh 'docker build -t ${IMAGE_DOCKER} .' } post { success { script { SUCCESS = 'true' STAGE = 'Docker Build' } } failure { script { SUCCESS = 'false' STAGE = 'Docker Build' } } aborted { script { SUCCESS = 'false' STAGE = 'Docker Build' } } } } stage('Docker Push') { when { equals expected: 'true', actual: SUCCESS } steps { withCredentials([usernamePassword(credentialsId: 'vodorodRegistry', passwordVariable: 'vodorodRegistryPassword', usernameVariable: 'vodorodRegistryUser')]) { sh "docker login registry.vodorod.cl -u ${env.vodorodRegistryUser} -p ${env.vodorodRegistryPassword}" sh 'docker push ${IMAGE_DOCKER}' } } post { success { script { SUCCESS = 'true' STAGE = 'Docker Push' } } failure { script { SUCCESS = 'false' STAGE = 'Docker Push' } } aborted { script { SUCCESS = 'false' STAGE = 'Docker Push' } } } } } post { success { script { withCredentials([string(credentialsId: 'telegramToken', variable: 'TOKEN'), string(credentialsId: 'telegramChatId', variable: 'CHAT_ID')]) { sh """ curl -s -X POST https://api.telegram.org/bot${TOKEN}/sendMessage -d chat_id=${CHAT_ID} -d parse_mode="HTML" -d text="Project : ${env.JOB_NAME} \nBranch: ${BRANCH_NAME} \nBuild : Complete \nStatus : Passed \nNode : ${env.NODE_NAME}" """ } } } failure { script { withCredentials([string(credentialsId: 'telegramToken', variable: 'TOKEN'), string(credentialsId: 'telegramChatId', variable: 'CHAT_ID')]) { sh """ curl -s -X POST https://api.telegram.org/bot${TOKEN}/sendMessage -d chat_id=${CHAT_ID} -d parse_mode="HTML" -d text="Project : ${env.JOB_NAME} \nBranch: ${BRANCH_NAME} \nBuild : ${STAGE} \nStatus : Failed \nNode : ${env.NODE_NAME}" """ } } } aborted { script { withCredentials([string(credentialsId: 'telegramToken', variable: 'TOKEN'), string(credentialsId: 'telegramChatId', variable: 'CHAT_ID')]) { sh """ curl -s -X POST https://api.telegram.org/bot${TOKEN}/sendMessage -d chat_id=${CHAT_ID} -d parse_mode="HTML" -d text="Project : ${env.JOB_NAME} \nBranch: ${BRANCH_NAME} \nBuild : ${STAGE} \nStatus : Aborted \nNode : ${env.NODE_NAME}" """ } } } } }