Skip to content

Commit 0b57cf1

Browse files
authored
update Jenkinsfile for cumulus migration (#869)
1 parent 5ae542c commit 0b57cf1

File tree

1 file changed

+2
-376
lines changed

1 file changed

+2
-376
lines changed

Jenkinsfile

+2-376
Original file line numberDiff line numberDiff line change
@@ -1,376 +1,2 @@
1-
String podSpec = '''
2-
apiVersion: v1
3-
kind: Pod
4-
spec:
5-
containers:
6-
- name: node
7-
image: node:16
8-
tty: true
9-
env:
10-
- name: HOME
11-
value: /home/jenkins/agent
12-
- name: TEST_ES_HOST
13-
value: http://localhost:9200
14-
resources:
15-
requests:
16-
memory: 768Mi
17-
cpu: 1000m
18-
limits:
19-
memory: 2560Mi
20-
cpu: 4000m
21-
- name: elasticsearch
22-
image: elasticsearch:7.17.1
23-
tty: true
24-
env:
25-
- name: discovery.type
26-
value: single-node
27-
- name: ES_JAVA_OPTS
28-
value: '-Xms512m -Xmx512m'
29-
command:
30-
- cat
31-
resources:
32-
requests:
33-
memory: 512Mi
34-
cpu: 1024m
35-
limits:
36-
memory: 1024Mi
37-
cpu: 1536m
38-
- name: docker
39-
image: docker:20-git
40-
tty: true
41-
env:
42-
- name: DOCKER_HOST
43-
value: tcp://localhost:2375
44-
- name: HOME
45-
value: /home/jenkins/agent
46-
resources:
47-
requests:
48-
memory: 256Mi
49-
cpu: 100m
50-
limits:
51-
memory: 512Mi
52-
cpu: 1024m
53-
- name: dind-daemon
54-
image: docker:18-dind
55-
securityContext:
56-
privileged: true
57-
runAsUser: 0
58-
volumeMounts:
59-
- name: docker-graph-storage
60-
mountPath: /var/lib/docker
61-
resources:
62-
requests:
63-
memory: 512Mi
64-
cpu: 100m
65-
limits:
66-
memory: 1536Mi
67-
cpu: 1500m
68-
securityContext:
69-
runAsUser: 1000
70-
volumes:
71-
- name: docker-graph-storage
72-
emptyDir: {}
73-
'''
74-
75-
pipeline {
76-
agent {
77-
kubernetes {
78-
yaml podSpec
79-
}
80-
}
81-
82-
environment {
83-
appName = 'arranger'
84-
dockerHubImageName = "overture/${appName}"
85-
gitHubRegistry = 'ghcr.io'
86-
gitHubRepo = "overture-stack/${appName}"
87-
githubImageName = "${gitHubRegistry}/${gitHubRepo}"
88-
chartsServer = 'https://overture-stack.github.io/charts-server/'
89-
90-
commit = sh(
91-
returnStdout: true,
92-
script: 'git describe --always'
93-
).trim()
94-
95-
version = sh(
96-
returnStdout: true,
97-
script:
98-
'cat lerna.json | ' +
99-
'grep "version" -m 1 | ' +
100-
'cut -d : -f2 | ' +
101-
"sed \'s:[\",]::g\'"
102-
).trim()
103-
104-
slackNotificationsUrl = credentials('OvertureSlackJenkinsWebhookURL')
105-
}
106-
107-
options {
108-
timeout(time: 30, unit: 'MINUTES')
109-
timestamps()
110-
}
111-
112-
stages {
113-
stage('Build modules') {
114-
steps {
115-
container('node') {
116-
sh 'npm ci'
117-
sh 'npm run bootstrap'
118-
}
119-
}
120-
}
121-
122-
stage('Run tests') {
123-
steps {
124-
container('elasticsearch') {
125-
withEnv(['JENKINS_NODE_COOKIE=do_not_kill']) {
126-
sh 'elasticsearch &'
127-
}
128-
}
129-
130-
container('node') {
131-
sh 'chmod +x -R ' + env.WORKSPACE
132-
sh 'npm run test -- --scope "@overture-stack/arranger-components"'
133-
sh 'npm run test -- --scope "@overture-stack/arranger-server"'
134-
sh 'docker/test/wait-for-es.sh \$TEST_ES_HOST npm run test -- --scope "integration-tests-*"'
135-
}
136-
}
137-
}
138-
139-
stage('Build images') {
140-
when {
141-
anyOf {
142-
branch 'develop'
143-
branch 'main'
144-
branch 'test'
145-
}
146-
}
147-
steps {
148-
container('docker') {
149-
sh "DOCKER_BUILDKIT=1 \
150-
docker build \
151-
--target server \
152-
--network=host \
153-
-f ./docker/Dockerfile.jenkins \
154-
-t server:${commit} ."
155-
}
156-
}
157-
}
158-
159-
stage('Tag git version') {
160-
when {
161-
branch 'main'
162-
}
163-
steps {
164-
container('docker') {
165-
withCredentials([usernamePassword(
166-
credentialsId: 'OvertureBioGithub',
167-
passwordVariable: 'GIT_PASSWORD',
168-
usernameVariable: 'GIT_USERNAME'
169-
)]) {
170-
sh "git tag v${version}"
171-
sh "git push https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/${gitHubRepo} --tags"
172-
}
173-
}
174-
}
175-
}
176-
177-
stage('Push images') {
178-
when {
179-
anyOf {
180-
branch 'develop'
181-
branch 'main'
182-
}
183-
}
184-
parallel {
185-
stage('...to dockerhub') {
186-
steps {
187-
container('docker') {
188-
withCredentials([usernamePassword(
189-
credentialsId:'OvertureDockerHub',
190-
passwordVariable: 'PASSWORD',
191-
usernameVariable: 'USERNAME'
192-
)]) {
193-
sh "docker login -u $USERNAME -p $PASSWORD"
194-
195-
script {
196-
if (env.BRANCH_NAME ==~ 'main') { // push latest and version tags
197-
sh "docker tag server:${commit} ${dockerHubImageName}-server:${version}"
198-
sh "docker push ${dockerHubImageName}-server:${version}"
199-
200-
sh "docker tag server:${commit} ${dockerHubImageName}-server:latest"
201-
sh "docker push ${dockerHubImageName}-server:latest"
202-
} else { // push commit tag
203-
sh "docker tag server:${commit} ${dockerHubImageName}-server:${commit}"
204-
sh "docker push ${dockerHubImageName}-server:${commit}"
205-
}
206-
207-
if (env.BRANCH_NAME ==~ 'develop') { // push edge tag
208-
sh "docker tag server:${commit} ${dockerHubImageName}-server:edge"
209-
sh "docker push ${dockerHubImageName}-server:edge"
210-
}
211-
}
212-
}
213-
}
214-
}
215-
}
216-
217-
stage('...to github') {
218-
steps {
219-
container('docker') {
220-
withCredentials([usernamePassword(
221-
credentialsId:'OvertureBioGithub',
222-
passwordVariable: 'PASSWORD',
223-
usernameVariable: 'USERNAME'
224-
)]) {
225-
sh "docker login ${gitHubRegistry} -u $USERNAME -p $PASSWORD"
226-
227-
script {
228-
if (env.BRANCH_NAME ==~ 'main') { //push edge and commit tags
229-
sh "docker tag server:${commit} ${githubImageName}-server:${version}"
230-
sh "docker push ${githubImageName}-server:${version}"
231-
232-
sh "docker tag server:${commit} ${githubImageName}-server:latest"
233-
sh "docker push ${githubImageName}-server:latest"
234-
} else { // push commit tag
235-
sh "docker tag server:${commit} ${githubImageName}-server:${commit}"
236-
sh "docker push ${githubImageName}-server:${commit}"
237-
}
238-
239-
if (env.BRANCH_NAME ==~ 'develop') { // push edge tag
240-
sh "docker tag server:${commit} ${githubImageName}-server:edge"
241-
sh "docker push ${githubImageName}-server:edge"
242-
}
243-
}
244-
}
245-
}
246-
}
247-
}
248-
}
249-
}
250-
251-
stage('Publish tag to npm') {
252-
when {
253-
branch 'main'
254-
}
255-
steps {
256-
container('node') {
257-
withCredentials([
258-
string(
259-
credentialsId: 'OvertureNPMAutomationToken',
260-
variable: 'NPM_TOKEN'
261-
)
262-
]) {
263-
script {
264-
// we still want to run the platform deploy even if this fails, hence try-catch
265-
try {
266-
sh 'git reset --hard HEAD'
267-
sh 'git pull --tags'
268-
sh "npm config set '//registry.npmjs.org/:_authToken' \"${NPM_TOKEN}\""
269-
sh 'PUBLISH_DECLARATIONS=true npm run publish::ci'
270-
// send a notification to the slack #overture-jenkins channel in OICR workspace
271-
sh "curl \
272-
-X POST \
273-
-H 'Content-type: application/json' \
274-
--data '{ \
275-
\"text\":\"New Arranger published succesfully: v.${version}\
276-
\n[Build ${env.BUILD_NUMBER}] (${env.BUILD_URL})\" \
277-
}' \
278-
${slackNotificationsUrl}"
279-
} catch (err) {
280-
echo 'There was an error while publishing packages'
281-
}
282-
}
283-
}
284-
}
285-
}
286-
}
287-
288-
// stage('Deploy to Overture QA') {
289-
// when {
290-
// branch 'develop'
291-
// }
292-
// steps {
293-
// build(job: '/Overture.bio/provision/helm', parameters: [
294-
// [$class: 'StringParameterValue', name: 'OVERTURE_ENV', value: 'qa' ],
295-
// [$class: 'StringParameterValue', name: 'OVERTURE_CHART_NAME', value: 'arranger'],
296-
// [$class: 'StringParameterValue', name: 'OVERTURE_RELEASE_NAME', value: 'arranger'],
297-
// [$class: 'StringParameterValue', name: 'OVERTURE_HELM_CHART_VERSION', value: ''], // use latest chart
298-
// [$class: 'StringParameterValue', name: 'OVERTURE_HELM_REPO_URL', value: chartsServer],
299-
// [$class: 'StringParameterValue', name: 'OVERTURE_HELM_REUSE_VALUES', value: "false" ],
300-
// [$class: 'StringParameterValue', name: 'OVERTURE_ARGS_LINE', value: "--set-string apiImage.tag=${commit} --set-string uiImage.tag=${commit}" ]
301-
// ])
302-
// }
303-
// }
304-
305-
// stage('Deploy to Overture Staging') {
306-
// when {
307-
// branch 'master'
308-
// }
309-
// steps {
310-
// build(job: '/Overture.bio/provision/helm', parameters: [
311-
// [$class: 'StringParameterValue', name: 'OVERTURE_ENV', value: 'staging' ],
312-
// [$class: 'StringParameterValue', name: 'OVERTURE_CHART_NAME', value: 'arranger'],
313-
// [$class: 'StringParameterValue', name: 'OVERTURE_RELEASE_NAME', value: 'arranger'],
314-
// [$class: 'StringParameterValue', name: 'OVERTURE_HELM_CHART_VERSION', value: ''], // use latest chart
315-
// [$class: 'StringParameterValue', name: 'OVERTURE_HELM_REPO_URL', value: chartsServer],
316-
// [$class: 'StringParameterValue', name: 'OVERTURE_HELM_REUSE_VALUES', value: "false" ],
317-
// [$class: 'StringParameterValue', name: 'OVERTURE_ARGS_LINE', value: "--set-string apiImage.tag=${version} --set-string uiImage.tag=${version}" ]
318-
// ])
319-
// }
320-
// }
321-
// }
322-
}
323-
324-
post {
325-
failure {
326-
container('node') {
327-
script {
328-
if (env.BRANCH_NAME ==~ /(develop|main|\S*[Tt]est\S*)/) {
329-
sh "curl \
330-
-X POST \
331-
-H 'Content-type: application/json' \
332-
--data '{ \
333-
\"text\":\"Build Failed: ${env.JOB_NAME}#${commit} \
334-
\n[Build ${env.BUILD_NUMBER}] (${env.BUILD_URL})\" \
335-
}' \
336-
${slackNotificationsUrl}"
337-
}
338-
}
339-
}
340-
}
341-
342-
fixed {
343-
container('node') {
344-
script {
345-
if (env.BRANCH_NAME ==~ /(develop|main|\S*[Tt]est\S*)/) {
346-
sh "curl \
347-
-X POST \
348-
-H 'Content-type: application/json' \
349-
--data '{ \
350-
\"text\":\"Build Fixed: ${env.JOB_NAME}#${commit} \
351-
\n[Build ${env.BUILD_NUMBER}] (${env.BUILD_URL})\" \
352-
}' \
353-
${slackNotificationsUrl}"
354-
}
355-
}
356-
}
357-
}
358-
359-
success {
360-
container('node') {
361-
script {
362-
if (env.BRANCH_NAME ==~ /(\S*[Tt]est\S*)/) {
363-
sh "curl \
364-
-X POST \
365-
-H 'Content-type: application/json' \
366-
--data '{ \
367-
\"text\":\"Build tested: ${env.JOB_NAME}#${commit} \
368-
\n[Build ${env.BUILD_NUMBER}] (${env.BUILD_URL})\" \
369-
}' \
370-
${slackNotificationsUrl}"
371-
}
372-
}
373-
}
374-
}
375-
}
376-
}
1+
@Library(value='jenkins-pipeline-library@master', changelog=false) _
2+
pipelineOVERTUREArranger()

0 commit comments

Comments
 (0)