-
-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathJenkinsfile
More file actions
145 lines (137 loc) · 3.64 KB
/
Jenkinsfile
File metadata and controls
145 lines (137 loc) · 3.64 KB
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
pipeline {
agent {
kubernetes {
label 'kubedeploy-agent'
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: kubectl
image: eclipsefdn/kubectl:okd-c1
command:
- cat
tty: true
resources:
limits:
cpu: 1
memory: 1Gi
volumeMounts:
- mountPath: "/home/default/.kube"
name: "dot-kube"
readOnly: false
- name: jnlp
resources:
limits:
cpu: 1
memory: 1Gi
volumes:
- name: "dot-kube"
emptyDir: {}
'''
}
}
environment {
APP_NAME = 'open-vsx-org'
NAMESPACE = 'foundation-internal-webdev-apps'
IMAGE_NAME = 'ghcr.io/eclipsefdn/openvsx-website'
CONTAINER_NAME = 'open-vsx-org'
IMAGE_TAG = sh(
script: """
if [ "${env.TAG_NAME}" = "" ]; then
printf ${env.TAG_NAME}-${env.BUILD_NUMBER}
else
printf \$(git rev-parse --short ${env.GIT_COMMIT})-${env.BUILD_NUMBER}
fi
""",
returnStdout: true
)
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 30, unit: 'MINUTES')
}
stages {
stage('Build docker image') {
agent {
label 'docker-build'
}
steps {
sh '''
docker build --pull -t ${IMAGE_NAME}:${IMAGE_TAG} .
'''
}
}
stage('Push docker image') {
agent {
label 'docker-build'
}
steps {
withDockerRegistry([credentialsId: 'a56a2346-7fc5-4f91-a624-073197e5f5c8', url: 'https://ghcr.io/']) {
sh '''
docker push ${IMAGE_NAME}:${IMAGE_TAG}
'''
}
}
}
stage('Deploy test') {
when {
branch 'test'
}
steps {
container('kubectl') {
withKubeConfig([credentialsId: 'ci-bot-okd-c1-token', serverUrl: 'https://api.okd-c1.eclipse.org:6443']) {
sh '''
./kubernetes/helm-deploy.sh test "${IMAGE_TAG}"
'''
}
}
}
}
stage('Deploy staging') {
when {
branch 'main'
}
steps {
container('kubectl') {
withKubeConfig([credentialsId: 'ci-bot-okd-c1-token', serverUrl: 'https://api.okd-c1.eclipse.org:6443']) {
sh '''
./kubernetes/helm-deploy.sh staging "${IMAGE_TAG}"
'''
}
}
}
}
stage('Deploy production') {
when {
branch 'production'
}
steps {
container('kubectl') {
withKubeConfig([credentialsId: 'ci-bot-okd-c1-token', serverUrl: 'https://api.okd-c1.eclipse.org:6443']) {
sh '''
./kubernetes/helm-deploy.sh production "${IMAGE_TAG}"
'''
}
}
}
}
}
post {
failure {
mail to: '[email protected]',
subject: "[open-vsx.org] Build Failure ${currentBuild.fullDisplayName} - ${env.BRANCH_NAME}",
mimeType: 'text/html',
body: "Project: ${env.JOB_NAME}<br/>Build Number: ${env.BUILD_NUMBER}<br/>Build URL: ${env.BUILD_URL}<br/>Console: ${env.BUILD_URL}/console"
}
fixed {
mail to: '[email protected]',
subject: "[open-vsx.org] Back to normal ${currentBuild.fullDisplayName} - ${env.BRANCH_NAME}",
mimeType: 'text/html',
body: "Project: ${env.JOB_NAME}<br/>Build Number: ${env.BUILD_NUMBER}<br/>Build URL: ${env.BUILD_URL}<br/>Console: ${env.BUILD_URL}/console"
}
cleanup {
deleteDir() /* clean up workspace */
}
}
}