Browse Source

jenkins prod

master
Mohsen Taba 1 week ago
parent
commit
bc5a81db87
  1. 23
      Jenkinsfile

23
Jenkinsfile

@ -11,7 +11,6 @@ pipeline {
when { expression { gitBranch == "origin/master" } }
steps {
script {
try {
withCredentials([usernamePassword(credentialsId: production_server_name, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh """
sshpass -p \$PASSWORD ssh -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -o ServerAliveCountMax=120 \$USERNAME@${production_server_ip} << 'EOF'
@ -44,29 +43,9 @@ pipeline {
EOF
"""
}
def lastCommit = sh(script: 'git log -1 --pretty=format:"%h - %s (%an)"', returnStdout: true).trim()
sh """
curl -F chat_id=1457670318 \
-F message_thread_id=6 \
-F document=@/var/jenkins_home/jobs/${env.JOB_NAME}/builds/${env.BUILD_NUMBER}/log \
-F caption='🚀 Dovodi Backend Deployment: SUCCESS \n📦 Project: #${env.JOB_NAME} \n🔗 Commit: ${lastCommit} \n🌐 URL: ${env.BUILD_URL}' \
https://api.telegram.org/bot7207581748:AAFeymryw7S44D86LYfWqYK-tSNeV3TOwBs/sendDocument
"""
} catch (Exception e) {
currentBuild.result = 'FAILURE'
def lastCommit = sh(script: 'git log -1 --pretty=format:"%h - %s (%an)"', returnStdout: true).trim()
sh """
curl -F chat_id=1457670318 \
-F message_thread_id=6 \
-F document=@/var/jenkins_home/jobs/${env.JOB_NAME}/builds/${env.BUILD_NUMBER}/log \
-F caption='❌ Dovodi Backend Deployment: FAILED \n📦 Project: #${env.JOB_NAME} \n🔗 Commit: ${lastCommit} \n🌐 URL: ${env.BUILD_URL}' \
https://api.telegram.org/bot7207581748:AAFeymryw7S44D86LYfWqYK-tSNeV3TOwBs/sendDocument
"""
throw e
}
}
}
}
}
}
Loading…
Cancel
Save