Skip to content

Commit a2be906

Browse files
authored
Merge pull request #233 from jfilipcz/disable-git-plugin-in-favor-of-git-clone
Replace git-plugin with shell git to ensure SSL settings are respected
2 parents 7ab51a4 + 9fb8972 commit a2be906

File tree

2 files changed

+50
-19
lines changed

2 files changed

+50
-19
lines changed

Diff for: docs/2-attack-of-the-pipelines/3a-jenkins.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Jenkins Pipeline
22

3-
> Jenkins is a tool that's been around for sometime but it's stuck with a lot of customers. It's a build server that's pretty dumb by nature but can be enhanced with lots of plugins and agents which is why it's such a powerful tool.
3+
> Jenkins is a tool that's been around for sometime but it's stuck with a lot of customers. It's a build server that's pretty dumb by nature but can be enhanced with lots of plugins and agents which is why it's such a powerful tool.
44
55
<!---
66
#### Jenkins access to GitLab
@@ -50,7 +50,7 @@ git push
5050
echo "https://$(oc get route jenkins --template='{{ .spec.host }}' -n ${TEAM_NAME}-ci-cd)/multibranch-webhook-trigger/invoke?token=pet-battle"
5151
```
5252
53-
Once you have the URL, over on GitLab go to `pet-battle > Settings > Integrations` to add the webhook
53+
Once you have the URL, over on GitLab go to `pet-battle > Settings > Integrations` to add the webhook
5454
![gitlab-webhook-trigger-fe.png](./images/gitlab-webhook-trigger-fe.png)
5555
5656
#### Jenkins Pipeline
@@ -142,10 +142,19 @@ git push
142142
6. Now that we've gone through what this stuff does, let's try fix the failing build. If you look at the output of the Jenkins job, you'll see it's not able to find anything in Nexus to put in a container. To fix this, update the `Jenkinsfile` by adding a new `stage` which will run app compilation, producing the artifact in Nexus for us. Add the following below to the `// 💥🔨 PIPELINE EXERCISE GOES HERE ` comment:
143143
144144
```groovy
145-
// 💥🔨 PIPELINE EXERCISE GOES HERE
145+
// 💥🔨 PIPELINE EXERCISE GOES HERE
146146
stage("🧰 Build (Compile App)") {
147147
agent { label "jenkins-agent-npm" }
148+
options {
149+
skipDefaultCheckout(true)
150+
}
148151
steps {
152+
sh '''
153+
git clone ${GIT_URL} pet-battle && cd pet-battle
154+
git checkout ${BRANCH_NAME}
155+
'''
156+
dir('pet-battle'){
157+
149158
script {
150159
env.VERSION = sh(returnStdout: true, script: "npm run version --silent").trim()
151160
env.PACKAGE = "${APP_NAME}-${VERSION}.tar.gz"
@@ -164,7 +173,7 @@ git push
164173
echo '### Running build ###'
165174
sh 'npm run build '
166175
167-
// 🌞 SONARQUBE SCANNING EXERCISE GOES HERE
176+
// 🌞 SONARQUBE SCANNING EXERCISE GOES HERE
168177
echo '### Running SonarQube ###'
169178
170179
echo '### Packaging App for Nexus ###'
@@ -173,6 +182,7 @@ git push
173182
curl -v -f -u ${NEXUS_CREDS} --upload-file ${PACKAGE} \
174183
http://nexus:8081/repository/${NEXUS_REPO_NAME}/${APP_NAME}/${PACKAGE}
175184
'''
185+
}
176186
}
177187
// 📰 Post steps go here
178188
}

Diff for: tests/doc-regression-test-files/3a-jenkins-Jenkinsfile.groovy

+36-15
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pipeline {
2121
GIT_CREDS = credentials("${OPENSHIFT_BUILD_NAMESPACE}-git-auth")
2222
NEXUS_CREDS = credentials("${OPENSHIFT_BUILD_NAMESPACE}-nexus-password")
2323

24-
// Nexus Artifact repo
24+
// Nexus Artifact repo
2525
NEXUS_REPO_NAME="labs-static"
2626
NEXUS_REPO_HELM = "helm-charts"
2727
}
@@ -86,10 +86,18 @@ pipeline {
8686
}
8787
}
8888

89-
// 💥🔨 PIPELINE EXERCISE GOES HERE
89+
// 💥🔨 PIPELINE EXERCISE GOES HERE
9090
stage("🧰 Build (Compile App)") {
9191
agent { label "jenkins-agent-npm" }
92+
options {
93+
skipDefaultCheckout(true)
94+
}
9295
steps {
96+
sh '''
97+
git clone ${GIT_URL} pet-battle && cd pet-battle
98+
git checkout ${BRANCH_NAME}
99+
'''
100+
dir('pet-battle'){
93101
script {
94102
env.VERSION = sh(returnStdout: true, script: "npm run version --silent").trim()
95103
env.PACKAGE = "${APP_NAME}-${VERSION}.tar.gz"
@@ -108,7 +116,7 @@ pipeline {
108116
echo '### Running build ###'
109117
sh 'npm run build '
110118

111-
// 🌞 SONARQUBE SCANNING EXERCISE GOES HERE
119+
// 🌞 SONARQUBE SCANNING EXERCISE GOES HERE
112120
echo '### Running SonarQube ###'
113121

114122
echo '### Packaging App for Nexus ###'
@@ -117,6 +125,7 @@ pipeline {
117125
curl -v -f -u ${NEXUS_CREDS} --upload-file ${PACKAGE} \
118126
http://nexus:8081/repository/${NEXUS_REPO_NAME}/${APP_NAME}/${PACKAGE}
119127
'''
128+
}
120129
}
121130
// 📰 Post steps go here
122131
}
@@ -132,7 +141,7 @@ pipeline {
132141
sh '''
133142
rm -rf package-contents*
134143
curl -v -f -u ${NEXUS_CREDS} http://nexus:8081/repository/${NEXUS_REPO_NAME}/${APP_NAME}/${PACKAGE} -o ${PACKAGE}
135-
# clean up
144+
# clean up
136145
oc delete bc/${APP_NAME} is/${APP_NAME} || rc=$?
137146
'''
138147
echo '### Run OpenShift Build ###'
@@ -150,7 +159,15 @@ pipeline {
150159

151160
stage("🏗️ Deploy - Helm Package") {
152161
agent { label "jenkins-agent-helm" }
162+
options {
163+
skipDefaultCheckout(true)
164+
}
153165
steps {
166+
sh '''
167+
git clone ${GIT_URL} pet-battle && cd pet-battle
168+
git checkout ${BRANCH_NAME}
169+
'''
170+
dir('pet-battle'){
154171
echo '### Lint Helm Chart ###'
155172
sh 'helm lint chart '
156173

@@ -167,21 +184,22 @@ pipeline {
167184
168185
# over write the chart name for features / sandbox dev
169186
yq eval -i .name=\\"${APP_NAME}\\" "chart/Chart.yaml"
170-
187+
171188
# probs point to the image inside ocp cluster or perhaps an external repo?
172189
yq eval -i .image_repository=\\"${IMAGE_REPOSITORY}\\" "chart/values.yaml"
173190
yq eval -i .image_name=\\"${APP_NAME}\\" "chart/values.yaml"
174191
yq eval -i .image_namespace=\\"${IMAGE_NAMESPACE}\\" "chart/values.yaml"
175-
192+
176193
# latest built image
177194
yq eval -i .image_version=\\"${VERSION}\\" "chart/values.yaml"
178195
'''
179196
echo '### Publish Helm Chart ###'
180197
sh '''
181-
# package and release helm chart - could only do this if release candidate only
182-
helm package --dependency-update chart/ --app-version ${VERSION}
198+
# package and release helm chart - could only do this if release candidate only
199+
helm package --dependency-update chart/ --app-version ${VERSION}
183200
curl -v -f -u ${NEXUS_CREDS} http://nexus:8081/repository/${NEXUS_REPO_HELM}/ --upload-file ${APP_NAME}-*.tgz
184201
'''
202+
}
185203
}
186204
}
187205

@@ -191,7 +209,7 @@ pipeline {
191209
stage("🏖️ Sandbox - Helm Install"){
192210
options {
193211
skipDefaultCheckout(true)
194-
}
212+
}
195213
agent { label "jenkins-agent-helm" }
196214
when {
197215
expression { return !(GIT_BRANCH.startsWith("master") || GIT_BRANCH.startsWith("main") )}
@@ -207,6 +225,9 @@ pipeline {
207225
}
208226
stage("🧪 TestEnv - ArgoCD Git Commit") {
209227
agent { label "jenkins-agent-argocd" }
228+
options {
229+
skipDefaultCheckout(true)
230+
}
210231
when {
211232
expression { GIT_BRANCH.startsWith("master") || GIT_BRANCH.startsWith("main") }
212233
}
@@ -216,7 +237,7 @@ pipeline {
216237
git clone https://${GIT_CREDS}@${ARGOCD_CONFIG_REPO} config-repo
217238
cd config-repo
218239
git checkout ${ARGOCD_CONFIG_REPO_BRANCH} # master or main
219-
240+
220241
PREVIOUS_VERSION=$(yq eval .applications.\\"${APP_NAME}\\".values.image_version "${ARGOCD_CONFIG_REPO_PATH}")
221242
PREVIOUS_CHART_VERSION=$(yq eval .applications.\\"${APP_NAME}\\".source_ref "${ARGOCD_CONFIG_REPO_PATH}")
222243
@@ -269,22 +290,22 @@ pipeline {
269290
// stage("🥾 Trigger System Tests") {
270291
// options {
271292
// skipDefaultCheckout(true)
272-
// }
293+
// }
273294
// agent { label "master" }
274295
// when {
275296
// expression { GIT_BRANCH.startsWith("master") || GIT_BRANCH.startsWith("main") }
276297
// }
277298
// steps {
278299
// echo "TODO - Run tests"
279-
// build job: "system-tests/main",
300+
// build job: "system-tests/main",
280301
// parameters: [[$class: 'StringParameterValue', name: 'APP_NAME', value: "${APP_NAME}" ],
281302
// [$class: 'StringParameterValue', name: 'CHART_VERSION', value: "${CHART_VERSION}"],
282-
// [$class: 'StringParameterValue', name: 'VERSION', value: "${VERSION}"]],
303+
// [$class: 'StringParameterValue', name: 'VERSION', value: "${VERSION}"]],
283304
// wait: false
284305
// }
285306
// }
286307

287-
// 💥🔨 BLUE / GREEN DEPLOYMENT GOES HERE
308+
// 💥🔨 BLUE / GREEN DEPLOYMENT GOES HERE
288309

289310
}
290-
}
311+
}

0 commit comments

Comments
 (0)