-
Notifications
You must be signed in to change notification settings - Fork 27
/
CompositeJenkinsfile
36 lines (35 loc) · 1.37 KB
/
CompositeJenkinsfile
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
MASTER_BRANCH = 'master'
pipeline {
agent { label 'jenkins-worker' }
options {
skipDefaultCheckout() // no checkout needed
buildDiscarder(logRotator(numToKeepStr: '100'))
timestamps()
}
stages {
stage('Trigger build') {
steps {
script {
def multiBranchJobPath = '../../hivemq-edge-composite'
def branchJobName = BRANCH_NAME.replace('/', '%2F')
try {
build job: "${multiBranchJobPath}/${branchJobName}", wait: false
} catch (e) {
try {
withCredentials([gitUsernamePassword(credentialsId: 'hivemq-jenkins')]) {
sh("git clone https://github.com/hivemq/hivemq-edge-composite.git --branch=${MASTER_BRANCH} --single-branch --depth 1 .")
try {
sh("git push origin HEAD:${BRANCH_NAME}")
} catch (e2) { // if push failed, branch already exists
}
}
} finally {
cleanWs()
build job: multiBranchJobPath, wait: false
}
}
}
}
}
}
}