-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkins_File
More file actions
71 lines (65 loc) · 2.09 KB
/
Jenkins_File
File metadata and controls
71 lines (65 loc) · 2.09 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
pipeline {
agent {
label 'master'
}
environment {
// Path to ansible executables directory. For example - /usr/bin or /opt/homebrew/bin
ANSIBLE_HOME = " . . . "
// Adding Ansible to PATH
PATH = "${env.ANSIBLE_HOME}:${env.PATH}"
// Inventory path
HOSTS = " . . . "
// Workspace with playbook
PLAYBOOK = " . . . "
// Telegram chat_id
CHAT_ID = " . . . "
// api.telegram.channel
TG_API = "https://api.telegram.org/ . . . "
}
stages {
stage('Git Pull') {
steps {
git(
branch: "main",
url: "git@github.com:MIRON0V/first_setup.git",
credentialsId: 'git'
)
}
}
stage('Prepare') {
steps {
script {
// Check Ansible version
sh 'ansible --version'
}
}
}
stage('Run Ansible Playbook') {
steps {
script {
sh '''#!/bin/bash
${ANSIBLE_HOME}/ansible-playbook -i ${HOSTS} ${PLAYBOOK}
'''
}
}
}
}
post {
// Telegram notifications
success {
sh ("""
curl -X POST -H 'Content-Type: application/json' -d '{"chat_id": "${CHAT_ID}", "text":"[😎SUCCESS] 🚀🔥💪 BREAKTHROUGH 🚀🔥💪", "disable _notification": false}' ${TG_API}
""")
}
aborted {
sh ("""
curl -X POST -H 'Content-Type: application/json' -d '{"chat_id": "${CHAT_ID}", "text":"[🫤ABORTED] 😐😑 Job was Finished 😐😑", "disable _notification": false}' ${TG_API}
""")
}
failure {
sh ("""
curl -X POST -H 'Content-Type: application/json' -d '{"chat_id": "${CHAT_ID}", "text":"[🤕FAILURE] 😭😞 The JOB Down 😭😞", "disable _notification": false}' ${TG_API}
""")
}
}
}