-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
160 lines (154 loc) · 6.28 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
pipeline {
options {
gitLabConnection("gitlab just-ai")
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))
disableConcurrentBuilds()
timeout(time: 60, unit: 'MINUTES')
timestamps()
}
agent {
label 'caila-dev-cloud-agent'
}
parameters {
string(name: "BRANCH", defaultValue: "dev", description: "")
booleanParam(name: "CHECK_SCHEMAS_ONLY", defaultValue: false, description: '')
}
stages {
stage('Prepare') {
steps {
script {
RESULT_BRANCH = env.gitlabBranch != null ? env.gitlabBranch : params.BRANCH
addBadge(cssClass: "badge-text--background badge-text--bordered", text: "${RESULT_BRANCH}")
echo "${env.gitlabBranch}"
}
updateGitlabCommitStatus name: "build", state: "running"
git url: "git@gitlab.just-ai.com:ml-platform-pub/mlp-java-sdk.git",
branch: "${RESULT_BRANCH}",
credentialsId: 'bitbucket_key'
}
}
stage('Update spec') {
steps {
script {
sh("./mlp-specs/update.sh")
def hasChanges = !sh(returnStdout: true, script: 'git status -s mlp-specs').trim().isEmpty()
if (hasChanges) {
sh("git commit -m 'Automatic update API spec from CI' mlp-specs")
sh("git push")
}
env.NEED_REBUILD = hasChanges || !params.CHECK_SCHEMAS_ONLY
}
}
}
stage('Build with maven') {
when {
expression { env.NEED_REBUILD == 'true' }
}
steps {
withMaven(maven: 'Maven 3.5', jdk: '11') {
sh """mvn versions:set -DnewVersion=${RESULT_BRANCH}-SNAPSHOT"""
sh """mvn clean deploy -U"""
sh """mvn deploy -P nexus-open-snapshot"""
}
}
}
stage('Rebuild MLP Services') {
when {
expression { RESULT_BRANCH in ['dev','stable','release'] }
}
steps {
parallel (
"build mlp-ai-proxy" : {
build job: "mlp-ai-proxy/${RESULT_BRANCH}", wait: false
},
"build mlp-aimyvoice-proxy-service" : {
build job: "mlp-aimyvoice-proxy-service-build/${RESULT_BRANCH}", wait: false
},
"build mlp-censorship-bot" : {
build job: "mlp-censorship-bot-build/${RESULT_BRANCH}", wait: false
},
"build mlp-chat-service" : {
build job: "mlp-chat-service-build/${RESULT_BRANCH}", wait: false
},
"build mlp-chit-chat-service" : {
build job: "mlp-chit-chat-service-build/${RESULT_BRANCH}", wait: false
},
"build mlp-cloud-dalle-service" : {
build job: "mlp-cloud-dalle-service-build/${RESULT_BRANCH}", wait: false
},
"build mlp-cloud-whisper-service" : {
build job: "mlp-cloud-whisper-service-build/${RESULT_BRANCH}", wait: false
},
"build mlp-cross-validation-service" : {
build job: "mlp-cross-validation-service-build/${RESULT_BRANCH}", wait: false
},
"build mlp-faq-service" : {
build job: "mlp-faq-service-build/${RESULT_BRANCH}", wait: false
},
"build mlp-gpt-mock" : {
build job: "mlp-gpt-mock-build/${RESULT_BRANCH}", wait: false
},
"build mlp-intents" : {
build job: "mlp-intents-build/${RESULT_BRANCH}", wait: false
},
"build mlp-justgpt-facade" : {
build job: "mlp-justgpt-facade-build/${RESULT_BRANCH}", wait: false
},
"build mlp-kaldi-asr-service" : {
build job: "mlp-kaldi-asr-service-build/${RESULT_BRANCH}", wait: false
},
"build mlp-loadtest-service" : {
build job: "mlp-loadtest-service-build/${RESULT_BRANCH}", wait: false
},
"build mlp-service-proxy" : {
build job: "mlp-service-proxy-build/${RESULT_BRANCH}", wait: false
},
"build mlp-summary-service" : {
build job: "mlp-summary-service-build/${RESULT_BRANCH}", wait: false
},
"build mlp-vectorize-service" : {
build job: "mlp-vectorize-service-build/${RESULT_BRANCH}", wait: false
}
,
)
}
}
stage('Merge release to stable') {
when {
expression {
RESULT_BRANCH == 'release'
}
}
steps {
sh """git checkout stable --force"""
sh """git pull origin stable"""
sh """git merge origin/release -m 'Automatic merge from release to stable'"""
sh """git push"""
}
}
stage('Merge stable to dev') {
when {
expression {
RESULT_BRANCH == 'stable'
}
}
steps {
sh """git checkout dev --force"""
sh """git pull origin dev"""
sh """git merge origin/stable -m 'Automatic merge from stable to dev'"""
sh """git push"""
}
}
}
post {
failure {
updateGitlabCommitStatus name: "build", state: "failed"
}
success {
updateGitlabCommitStatus name: "build", state: "success"
}
unstable {
updateGitlabCommitStatus name: "build", state: "failed"
}
}
}