|
|
@ -0,0 +1,52 @@ |
|
|
|
|
|
pipeline { |
|
|
|
|
|
environment { |
|
|
|
|
|
develop_server_ip = '' |
|
|
|
|
|
develop_server_name = '' |
|
|
|
|
|
production_server_ip = "88.99.212.243" |
|
|
|
|
|
production_server_name = "newhorizon_germany_001_server" |
|
|
|
|
|
project_path = "/projects/teamby/teamby_landing" |
|
|
|
|
|
version = "master" |
|
|
|
|
|
gitBranch = "origin/master" |
|
|
|
|
|
} |
|
|
|
|
|
agent any |
|
|
|
|
|
stages { |
|
|
|
|
|
stage('deploy') { |
|
|
|
|
|
steps { |
|
|
|
|
|
script { |
|
|
|
|
|
if (gitBranch == "origin/master") { |
|
|
|
|
|
try { |
|
|
|
|
|
withCredentials([usernamePassword(credentialsId: production_server_name, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { |
|
|
|
|
|
sh 'sshpass -p $PASSWORD ssh -p 1782 $USERNAME@$production_server_ip -o StrictHostKeyChecking=no "cd $project_path && ./runner.sh"' |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
def lastCommit = sh(script: 'git log -1 --pretty=format:"%h - %s (%an)"', returnStdout: true).trim() |
|
|
|
|
|
sh """ |
|
|
|
|
|
curl -s -F chat_id=-1002316394394 \ |
|
|
|
|
|
-F message_thread_id=1629 \ |
|
|
|
|
|
-F document=@/var/jenkins_home/jobs/${env.JOB_NAME}/builds/${env.BUILD_NUMBER}/log \ |
|
|
|
|
|
-F caption='Project name: #${env.JOB_NAME} \ |
|
|
|
|
|
Build status is FAILED \ |
|
|
|
|
|
Build url: ${BUILD_URL} \ |
|
|
|
|
|
Last Commit: ${lastCommit}' \ |
|
|
|
|
|
https://api.telegram.org/bot7207581748:AAH1y1pW8L9K_jWlKx3Xj_xV3pZl4Zq9V1Y/sendDocument || true |
|
|
|
|
|
""" |
|
|
|
|
|
currentBuild.result = 'FAILURE' |
|
|
|
|
|
throw e |
|
|
|
|
|
} |
|
|
|
|
|
def lastCommit = sh(script: 'git log -1 --pretty=format:"%h - %s (%an)"', returnStdout: true).trim() |
|
|
|
|
|
sh """ |
|
|
|
|
|
curl -s -F chat_id=-1002316394394 \ |
|
|
|
|
|
-F message_thread_id=1629 \ |
|
|
|
|
|
-F document=@/var/jenkins_home/jobs/${env.JOB_NAME}/builds/${env.BUILD_NUMBER}/log \ |
|
|
|
|
|
-F caption='Project name: #${env.JOB_NAME} \ |
|
|
|
|
|
Build status is SUCCESS \ |
|
|
|
|
|
Build url: ${BUILD_URL} \ |
|
|
|
|
|
Last Commit: ${lastCommit}' \ |
|
|
|
|
|
https://api.telegram.org/bot7207581748:AAH1y1pW8L9K_jWlKx3Xj_xV3pZl4Zq9V1Y/sendDocument || true |
|
|
|
|
|
""" |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |