-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
53 lines (48 loc) · 2.09 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// ::NOTIFICATION
def telegram_url = "https://api.telegram.org/bot5021645900:AAFxQI0ltL5dRTNHqLfhg1Ko1ll7hUujjp8/sendMessage"
def telegram_chatid = "-1001131394773"
def job_success = "SUCCESS"
def job_error = "ERROR"
node ('jobs') {
try {
stage('Ready to Deploy') {
echo 'Ready'
}
stage('Deployment') {
echo "deploy to apache2"
sshagent(credentials: ['Apache2']) {
sh "pwd"
sh "ls"
sh 'scp -r * /var/lib/jenkins/workspace/admin-dashboard/ [email protected]:/var/www/html/stroberi'
//ssh "cd /var/www/html/stroberi && pwd && git pull origin master"
}
}
stage ("Notifications") {
deleteDir()
echo "Job Success"
notifications(telegram_url: telegram_url, telegram_chatid: telegram_chatid,
job: env.JOB_NAME, job_numb: env.BUILD_NUMBER, job_url: env.BUILD_URL, job_status: job_success
)
}
} catch (e) {
stage ("Error") {
deleteDir()
echo "Job Failed"
notifications(telegram_url: telegram_url, telegram_chatid: telegram_chatid,
job: env.JOB_NAME, job_numb: env.BUILD_NUMBER, job_url: env.BUILD_URL, job_status: job_error
)
}
}
}
def notifications(Map args) {
def message = " Dear Team \n CICD Pipeline ${args.job} ${args.job_status} with build ${args.job_numb} \n\n More info at: ${args.job_url} \n\n Total Time : ${currentBuild.durationString}"
sh "curl -s -X POST ${args.telegram_url} -d chat_id=${args.telegram_chatid} -d text='${message}'"
//parallel(
// "Telegram": {
// sh "curl -s -X POST ${args.telegram_url} -d chat_id=${args.telegram_chatid} -d text='${message}'"
// },
// "Jira": {
//jiraSend color: "${args.jira_url}", message: "${message}", channel: "${args.slack_channel}"
// }
//)
}