-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJenkinsfile
More file actions
66 lines (61 loc) · 1.89 KB
/
Copy pathJenkinsfile
File metadata and controls
66 lines (61 loc) · 1.89 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
pipeline {
agent any
environment {
JOB = 'Techscrum-Main-branch-Pipeline'
JOB_URL = 'http://34.129.229.29:8080/job/Techscrum-Main-branch-Pipeline/'
}
stages {
stage('Checkout') {
steps {
git(branch: 'jenkins', credentialsId: 'jenkins_node', url: 'git@github.com:Topsc/Techscrum.be.git')
}
}
}
post {
always {
script {
checkAndTriggerDownstreamJobs()
}
}
}
post {
failure {
emailext attachLog: true, body: "The pipeline ${JOB} has failed. Please check the Jenkins job at ${JOB_URL}", subject: "Failed Pipeline: ${JOB}", to: "devopstechscrum@outlook.com"
}
}
}
@NonCPS
def checkAndTriggerDownstreamJobs() {
def changeLogSets = currentBuild.changeSets
def frontendChanged = false
def backendChanged = false
def monitorChanged = false
for (int i = 0; i < changeLogSets.size(); i++) {
def entries = changeLogSets[i].items
for (int j = 0; j < entries.length; j++) {
def entry = entries[j]
def affectedFiles = entry.affectedFiles
for (int k = 0; k < affectedFiles.size(); k++) {
def file = affectedFiles[k]
if (file.path.contains("FrontendTF")) {
frontendChanged = true
}
if (file.path.contains("backend")) {
backendChanged = true
}
if (file.path.contains("opensearch_and_monitor")) {
monitorChanged = true
}
}
}
}
if (frontendChanged) {
build job: 'techscrum-frontend-terraform-pipeline', wait: true
}
if (backendChanged) {
build job: 'Backend-terraform', wait: true
}
if (monitorChanged) {
build job: 'opensearch_and_monitor', wait: true
}
}