forked from gyroidos/meta-trustx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
43 lines (37 loc) · 1.32 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
pipeline {
agent any
parameters {
string(name: 'CI_LIB_VERSION', defaultValue: 'main', description: 'Version of gyroidos_ci_common to use for this build')
string(name: 'PR_BRANCHES', defaultValue: '', description: 'Comma separated list of additional pull request branches (e.g. meta-trustx=PR-177,meta-trustx-nxp=PR-13,gyroidos_build=PR-97)')
}
stages {
stage('build GyroidOS') {
steps {
script {
REPO_NAME = determineRepoName()
if (env.CHANGE_TARGET != null) {
// in case this is a PR build
// set the BASE_BRANCH to the target
// e.g. PR-123 -> kirkstone
BASE_BRANCH = env.CHANGE_TARGET
} else {
// in case this is a regular build
// let the BASE_BRANCH equal this branch
// e.g. kirkstone -> kirkstone
BASE_BRANCH = env.BRANCH_NAME
}
}
build job: "../gyroidos/${BASE_BRANCH}", wait: true, parameters: [
string(name: "CI_LIB_VERSION", value: CI_LIB_VERSION),
string(name: "PR_BRANCHES", value: "${REPO_NAME}=${env.BRANCH_NAME},${env.PR_BRANCHES}")
]
}
}
}
}
// Determine the Repository name from its URL.
// Avoids hardcoding the name in every Jenkinsfile individually.
// Source: https://stackoverflow.com/a/45690925
String determineRepoName() {
return scm.getUserRemoteConfigs()[0].getUrl().tokenize('/').last().split("\\.")[0]
}