-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
48 lines (40 loc) · 1.77 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
pipeline {
agent any
stages {
stage('Ready To Deploy') {
steps{
echo "ready"
}
}
stage('Deployment To Server') {
steps{
echo "deploy to apache2"
sshagent(credentials: ['Apache2']) {
sh "cd .."
sh "ls"
sh "curl -s -X POST https://api.telegram.org/bot5021645900:AAFxQI0ltL5dRTNHqLfhg1Ko1ll7hUujjp8/sendMessage -d chat_id=-1001131394773 -d text='mejeh'"
sh "scp -r * [email protected]:/var/www/html/stroberi"
//sh "ssh [email protected] cd /var/www/html/stroberi && pwd && git pull origin master"
}
}
}
stage("Notifications") {
steps{
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, unitTest_score: unitTest_score
)
}
} catch (e) {
stage("Error") {
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, unitTest_score: unitTest_score
)
}
}
}
}
}
def notifications(Map args) {
def message = " Dear Team PRH \n CICD Pipeline ${args.job} ${args.job_status} with build ${args.job_numb} \n\n More info at: ${args.job_url} \n\n Unit Test: ${args.unitTest_score} \n\n Total Time : ${currentBuild.durationString}"