-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
77 lines (75 loc) · 2.75 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
pipeline {
options {
gitLabConnection("gitlab just-ai")
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))
disableConcurrentBuilds()
timeout(time: 180, unit: 'MINUTES')
timestamps()
}
agent {
label 'caila-dev-cloud-agent'
}
parameters {
extendedChoice(name: 'COMPONENTS',
value: 'python-client,python-composite-action,python-fit-action,python-rest-client,python-simple-action',
defaultValue: 'python-client,python-composite-action,python-fit-action,python-rest-client,python-simple-action',
description: '', descriptionPropertyValue: '', multiSelectDelimiter: ',', quoteValue: false, saveJSONParameterToFile: false, type: 'PT_MULTI_SELECT', visibleItemCount: 5)
}
stages {
stage('notify gitlab') {
steps {
updateGitlabCommitStatus name: "build", state: "running"
}
}
stage('Build') {
steps {
script {
echo "========================================================="
echo params.COMPONENTS
for (cmp in params.COMPONENTS.split(",")) {
stage("Build ${cmp}") {
script {
echo "========================================================="
echo cmp
try {
sh """cd ${WORKSPACE}/${cmp} && sh ./build.sh ${env.BRANCH_NAME}"""
} catch(Exception e) {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
error("build ${cmp} failed.")
}
}
}
}
}
}
}
}
stage('Merge release to main') {
when {
expression {
env.BRANCH_NAME == 'release'
}
}
steps {
sh """git checkout main --force"""
sh """git pull"""
sh """git merge origin/release -m 'Automatic merge from release to main'"""
sh """git push"""
}
}
}
post {
// always {
// cleanWs()
// }
failure {
updateGitlabCommitStatus name: "build", state: "failed"
}
success {
updateGitlabCommitStatus name: "build", state: "success"
}
unstable {
updateGitlabCommitStatus name: "build", state: "failed"
}
}
}