forked from AlfrescoArchive/example-cloud-connector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
167 lines (143 loc) · 4.29 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
pipeline {
agent {
kubernetes {
// Change the name of jenkins-maven label to be able to use yaml configuration snippet
label "maven-jenkins"
// Inherit from Jx Maven pod template
inheritFrom "maven"
// Add scheduling configuration to Jenkins builder pod template
yaml """
spec:
nodeSelector:
cloud.google.com/gke-preemptible: true
# It is necessary to add toleration to GKE preemtible pool taint to the pod in order to run it on that node pool
tolerations:
- key: gke-preemptible
operator: Equal
value: true
effect: NoSchedule
# Create sidecar container with gsutil to publish chartmuseum index.yaml to Google bucket storage
volumes:
- name: gsutil-volume
secret:
secretName: gsutil-secret
items:
- key: .boto
path: .boto
containers:
- name: cloud-sdk
image: google/cloud-sdk:alpine
command:
- /bin/sh
- -c
args:
- gcloud config set pass_credentials_to_gsutil false && cat
workingDir: /home/jenkins
securityContext:
privileged: false
tty: true
resources:
requests:
cpu: 128m
memory: 256Mi
limits:
volumeMounts:
- mountPath: /home/jenkins
name: workspace-volume
- name: gsutil-volume
mountPath: /root/.boto
subPath: .boto
"""
}
}
environment {
ORG = "introproventures"
APP_NAME = "example-cloud-connector"
CHARTMUSEUM_CREDS = credentials("jenkins-x-chartmuseum")
CHARTMUSEUM_GS_BUCKET = "introproventures"
}
stages {
stage("CI Build and push snapshot") {
when {
branch "PR-*"
}
environment {
PREVIEW_VERSION = "0.0.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER"
PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase()
HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase()
}
steps {
container("maven") {
sh "make preview-version"
sh "make install"
sh "make skaffold/preview"
sh "make helm/preview"
}
}
}
stage("Build Release") {
when {
branch "develop"
}
environment {
RELEASE_BRANCH = "develop"
CHART_REPOSITORY = "http://jenkins-x-chartmuseum:8080"
GITHUB_CHARTS_REPO = "https://github.com/igdianov/helm-charts.git"
}
steps {
container("maven") {
// ensure we're not on a detached head
sh "make checkout"
// so we can retrieve the version in later steps
sh "make next-version"
// Let's test first
sh "make install"
// Let's build and lint Helm chart
sh "make helm/build"
// Let's make tag in Git
sh "make tag"
// Let's deploy to Nexus
sh "make deploy"
// Let's build and push Docker image
sh "make skaffold/release"
// Let's release chart into Chartmuseum
sh "make helm/release"
// Let's release chart into Github repository
sh "make helm/github"
}
container("cloud-sdk") {
// Let's update index.yaml in Chartmuseum storage bucket
sh "curl --fail -L ${CHART_REPOSITORY}/index.yaml | gsutil cp - gs://${CHARTMUSEUM_GS_BUCKET}/index.yaml"
}
}
}
stage("Promote to Environments") {
when {
branch "develop"
}
environment {
PROMOTE_HELM_REPO_URL = "https://storage.googleapis.com/$CHARTMUSEUM_GS_BUCKET"
}
steps {
container("maven") {
// Let's make changelog in Github
sh "make changelog"
// promote through all 'Auto' promotion Environments
sh "make helm/promote"
}
}
}
}
post {
always {
cleanWs()
}
/*
failure {
input """Pipeline failed.
We will keep the build pod around to help you diagnose any failures.
Select Proceed or Abort to terminate the build pod"""
}
*/
}
}