-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
125 lines (114 loc) · 4.01 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
def dockerRepo = "ghcr.io/icgc-argo/workflow-gateway"
def gitHubRepo = "icgc-argo/workflow-gateway"
def chartVersion = "0.3.0"
def commit = "UNKNOWN"
def version = "UNKNOWN"
pipeline {
agent {
kubernetes {
label 'wf-gateway'
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: helm
image: alpine/helm:2.12.3
command:
- cat
tty: true
- name: dind-daemon
image: docker:18.06-dind
securityContext:
privileged: true
runAsUser: 0
volumeMounts:
- name: docker-graph-storage
mountPath: /var/lib/docker
- name: docker
image: docker:18-git
tty: true
env:
- name: DOCKER_HOST
value: tcp://localhost:2375
- name: HOME
value: /home/jenkins/agent
securityContext:
runAsUser: 1000
volumes:
- name: docker-graph-storage
emptyDir: {}
"""
}
}
stages {
stage('Prepare') {
steps {
script {
commit = sh(returnStdout: true, script: 'git describe --always').trim()
version = sh(returnStdout: true, script: 'head -1 VERSION').trim()
}
}
}
stage('Build & Publish Develop') {
when {
branch "develop"
}
steps {
container('docker') {
withCredentials([usernamePassword(credentialsId:'argoContainers', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'docker login ghcr.io -u $USERNAME -p $PASSWORD'
}
// DNS error if --network is default
sh "docker build --network=host . -t ${dockerRepo}:edge -t ${dockerRepo}:${version}-${commit}"
sh "docker push ${dockerRepo}:${version}-${commit}"
sh "docker push ${dockerRepo}:edge"
}
}
}
stage('deploy to rdpc-collab-dev') {
when {
branch "develop"
}
steps {
build(job: "/provision/update-app-version", parameters: [
[$class: 'StringParameterValue', name: 'RDPC_ENV', value: 'dev' ],
[$class: 'StringParameterValue', name: 'TARGET_RELEASE', value: 'gateway'],
[$class: 'StringParameterValue', name: 'NEW_APP_VERSION', value: "${version}-${commit}" ]
])
}
}
stage('Release & Tag') {
when {
branch "master"
}
steps {
container('docker') {
withCredentials([usernamePassword(credentialsId: 'argoGithub', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
sh "git tag ${version}"
sh "git push https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/${gitHubRepo} --tags"
}
withCredentials([usernamePassword(credentialsId:'argoContainers', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'docker login ghcr.io -u $USERNAME -p $PASSWORD'
}
// DNS error if --network is default
sh "docker build --network=host . -t ${dockerRepo}:latest -t ${dockerRepo}:${version}"
sh "docker push ${dockerRepo}:${version}"
sh "docker push ${dockerRepo}:latest"
}
}
}
stage('deploy to rdpc-collab-qa') {
when {
branch "master"
}
steps {
build(job: "/provision/update-app-version", parameters: [
[$class: 'StringParameterValue', name: 'RDPC_ENV', value: 'qa' ],
[$class: 'StringParameterValue', name: 'TARGET_RELEASE', value: 'gateway'],
[$class: 'StringParameterValue', name: 'NEW_APP_VERSION', value: "${version}" ]
])
}
}
}
}