-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
242 lines (222 loc) · 13.6 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
String cron_working_branch = BRANCH_NAME != "develop" && BRANCH_NAME != "sandbox" ? "@daily" : ""
pipeline {
triggers {
cron(cron_working_branch)
}
agent {
label 'java11'
}
stages {
stage('Preparation') {
steps {
sh 'echo "Starting CI/CD Pipeline"'
}
}
stage('Compile') {
parallel {
stage('Compile JAVA') {
steps {
sh '''
mvn -Dmaven.test.failure.ignore=true -s '/home/jenkins/.m2/settings.xml' clean install
'''
}
post {
failure {
slackSend baseUrl: 'https://altia-alicante.slack.com/services/hooks/jenkins-ci/', channel: 'reportnet3', message: 'Build FAILED - JAVA Compilation Error in branch ' + env.BRANCH_NAME.replace('/', '_'), token: 'HRvukH8087RNW9NYQ3fd6jtM'
}
always {
junit '**/target/surefire-reports/*.xml'
}
}
}
/*stage('Compile NPM') {
steps {
sh 'rm -rf /node_modules/'
sh 'rm -f package-lock.json'
sh '''
npm install --no-cache frontend-service/
'''
}
}*/
}
}
stage('Install in Nexus') {
when {
branch 'develop1'
}
parallel {
stage('Install in JAVA repository') {
steps {
sh '''
mvn -Dmaven.test.skip=true -s '/home/jenkins/.m2/settings.xml' deploy
'''
}
}
stage('Install in NPM repository') {
steps {
sh '''
npm publish frontend-service/ --registry=https://nexus-oami.altia.es/content/repositories/npm-internal/
'''
}
}
}
}
stage('Push to EEA GitHub') {
when {
branch 'release/v3.1.5.5-RC1'
}
steps {
withCredentials([usernamePassword(credentialsId: 'jenkins-eea-altia', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
sh('git config --global user.email "ext.jose.luis.anton@altia.es"')
sh('git config --global user.name "Jose Luis Anton (ALTIA)"')
sh('git pull https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/eea/eea.reportnet3.git develop --allow-unrelated-histories')
sh('git push https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/eea/eea.reportnet3.git HEAD:develop')
}
}
}
stage('Setup sandbox docker images build'){
steps{
script {
if (env.BRANCH_NAME == 'sandbox') {
env.TAG_SUFIX="_sandbox"
} else {
env.TAG_SUFIX=""
}
env.DATAFLOW_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=dataflow.version -q -DforceStdout', returnStdout: true
env.DATASET_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=dataset.version -q -DforceStdout', returnStdout: true
env.RECORDSTORE_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=recordstore.version -q -DforceStdout', returnStdout: true
env.VALIDATION_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=validation.version -q -DforceStdout', returnStdout: true
env.ORCHESTRATOR_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=orchestrator.version -q -DforceStdout', returnStdout: true
env.COLLABORATION_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=collaboration.version -q -DforceStdout', returnStdout: true
env.DOCUMENT_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=document.version -q -DforceStdout', returnStdout: true
env.API_GATEWAY_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=api-gateway.version -q -DforceStdout', returnStdout: true
env.INSPIRE_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=inspire.version -q -DforceStdout', returnStdout: true
env.COMMUNICATION_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=communication.version -q -DforceStdout', returnStdout: true
env.INDEXSEARCH_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=indexsearch.version -q -DforceStdout', returnStdout: true
env.UMS_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=ums.version -q -DforceStdout', returnStdout: true
env.FRONTEND_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=frontend.version -q -DforceStdout', returnStdout: true
env.ROD_VERSION = sh script: 'mvn -f $WORKSPACE/parent-poms/parent/pom.xml help:evaluate -Dexpression=rod.version -q -DforceStdout', returnStdout: true
}
}
}
stage('Build Docker Images') {
when {
expression {
return BRANCH_NAME == "develop"
}
}
parallel {
stage('Build Core Platform') {
steps {
script {
echo 'Dataflow Service'
def app
app = docker.build("k8s-swi001:5000/dataflow-service:1.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/dataflow-service-" + env.DATAFLOW_VERSION + ".jar --build-arg MS_PORT=8020 -f ./Dockerfile ./dataflow-service")
app.push()
sh 'docker rmi k8s-swi001:5000/dataflow-service:1.0${TAG_SUFIX}'
}
script {
echo 'Dataset Service'
def app
app = docker.build("k8s-swi001:5000/dataset-service:1.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/dataset-service-" + env.DATAFLOW_VERSION + ".jar --build-arg MS_PORT=8030 -f ./Dockerfile ./dataset-service")
app.push()
sh 'docker rmi k8s-swi001:5000/dataset-service:1.0${TAG_SUFIX}'
}
script {
echo 'Recordstore Service'
def app
app = docker.build("k8s-swi001:5000/recordstore-service:3.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/recordstore-service-" + env.RECORDSTORE_VERSION + ".jar --build-arg MS_PORT=8090 ./recordstore-service/")
app.push()
sh 'docker rmi k8s-swi001:5000/recordstore-service:3.0${TAG_SUFIX}'
}
script {
echo 'Validation Service'
def app
app = docker.build("k8s-swi001:5000/validation-service:1.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/validation-service-" + env.VALIDATION_VERSION + ".jar --build-arg MS_PORT=8015 -f ./Dockerfile ./validation-service")
app.push()
sh 'docker rmi k8s-swi001:5000/validation-service:1.0${TAG_SUFIX}'
}
script {
echo 'Orchestrator Service'
def app
app = docker.build("k8s-swi001:5000/orchestrator-service:1.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/orchestrator-service-" + env.ORCHESTRATOR_VERSION + ".jar --build-arg MS_PORT=8091 -f ./Dockerfile ./orchestrator-service")
app.push()
sh 'docker rmi k8s-swi001:5000/orchestrator-service:1.0${TAG_SUFIX}'
}
script {
echo 'Collaboration Service'
def app
app = docker.build("k8s-swi001:5000/collaboration-service:3.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/collaboration-service-" + env.COLLABORATION_VERSION + ".jar --build-arg MS_PORT=9010 -f ./Dockerfile ./collaboration-service")
app.push()
sh 'docker rmi k8s-swi001:5000/collaboration-service:3.0${TAG_SUFIX}'
}
script {
echo 'Document Container Service'
def app
app = docker.build("k8s-swi001:5000/document-container-service:3.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/document-container-service-" + env.DOCUMENT_VERSION + ".jar --build-arg MS_PORT=9040 -f ./Dockerfile ./document-container-service")
app.push()
sh 'docker rmi k8s-swi001:5000/document-container-service:3.0${TAG_SUFIX}'
}
}
}
stage('Build Integration Layer') {
steps{
script {
echo 'API Gateway'
def app
app = docker.build("k8s-swi001:5000/api-gateway:1.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/api-gateway-" + env.API_GATEWAY_VERSION + ".jar --build-arg MS_PORT=8010 -f ./Dockerfile ./api-gateway ")
app.push()
sh 'docker rmi k8s-swi001:5000/api-gateway:1.0${TAG_SUFIX}'
}
script {
echo 'Inspire Harvester'
def app
app = docker.build("k8s-swi001:5000/inspire-harvester:3.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/inspire-harvester-" + env.INSPIRE_VERSION + ".jar --build-arg MS_PORT=8050 -f ./Dockerfile ./inspire-harvester ")
app.push()
sh 'docker rmi k8s-swi001:5000/inspire-harvester:3.0${TAG_SUFIX}'
}
script {
echo 'Communication Service'
def app
app = docker.build("k8s-swi001:5000/communication-service:3.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/communication-service-" + env.COMMUNICATION_VERSION + ".jar --build-arg MS_PORT=9020 -f ./Dockerfile ./communication-service")
app.push()
sh 'docker rmi k8s-swi001:5000/communication-service:3.0${TAG_SUFIX}'
}
script {
echo 'IndexSearch Service'
def app
app = docker.build("k8s-swi001:5000/indexsearch-service:3.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/indexsearch-service-" + env.INDEXSEARCH_VERSION + ".jar --build-arg MS_PORT=9030 -f ./Dockerfile ./indexsearch-service")
app.push()
sh 'docker rmi k8s-swi001:5000/indexsearch-service:3.0${TAG_SUFIX}'
}
script {
echo 'User Management Service'
def app
app = docker.build("k8s-swi001:5000/user-management-service:3.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/user-management-service-" + env.UMS_VERSION + ".jar --build-arg MS_PORT=9010 -f ./Dockerfile ./user-management-service")
app.push()
sh 'docker rmi k8s-swi001:5000/user-management-service:3.0${TAG_SUFIX}'
}
script {
echo 'ROD Service'
def app
app = docker.build("k8s-swi001:5000/rod-service:3.0" + env.TAG_SUFIX, "--build-arg JAR_FILE=target/rod-service-" + env.ROD_VERSION + ".jar --build-arg MS_PORT=9050 -f ./Dockerfile ./rod-service")
app.push()
sh 'docker rmi k8s-swi001:5000/rod-service:3.0${TAG_SUFIX}'
}
}
}
stage('Build Frontend') {
steps {
script {
echo 'ReportNet 3.0 Frontend'
def app
app = docker.build("k8s-swi001:5000/reportnet-frontend-service:3.0" + env.TAG_SUFIX, " ./frontend-service/")
app.push()
sh 'docker rmi k8s-swi001:5000/reportnet-frontend-service:3.0${TAG_SUFIX}'
}
}
}
}
}
}
}