Skip to content

Commit 0f1a868

Browse files
Merge pull request #16880 from coreydaley/trello_1148_jenkins_pipeline_example
Automatic merge from submit-queue. Adding sample Jenkins Pipeline Adding a sample Jenkins Pipeline in support of documentation updates. Supports: openshift/openshift-docs#5720 Trello: https://trello.com/c/rBojNLGj/1121-5-better-devguide-pipeline-docs-techdebt
2 parents eecb026 + 2d1bea7 commit 0f1a868

File tree

3 files changed

+274
-0
lines changed

3 files changed

+274
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
kind: "BuildConfig"
2+
apiVersion: "v1"
3+
metadata:
4+
name: "nodejs-sample-pipeline"
5+
spec:
6+
strategy:
7+
jenkinsPipelineStrategy:
8+
jenkinsfile: |-
9+
// path of the template to use
10+
def templatePath = 'https://raw.githubusercontent.com/openshift/nodejs-ex/master/openshift/templates/nodejs-mongodb.json'
11+
// name of the template that will be created
12+
def templateName = 'nodejs-mongodb-example'
13+
openshift.withCluster() {
14+
openshift.withProject() {
15+
echo "Using project: ${openshift.project()}"
16+
pipeline {
17+
agent {
18+
node {
19+
// spin up a node.js slave pod to run this build on
20+
label 'nodejs'
21+
}
22+
}
23+
options {
24+
// set a timeout of 20 minutes for this pipeline
25+
timeout(time: 20, unit: 'MINUTES')
26+
}
27+
stages {
28+
stage('cleanup') {
29+
steps {
30+
// delete everything with this template label
31+
openshift.selector("all", [ template : templateName ]).delete()
32+
// delete any secrets with this template label
33+
if (openshift.selector("secrets", templateName).exists()) {
34+
openshift.selector("secrets", templateName).delete()
35+
}
36+
}
37+
}
38+
stage('create') {
39+
steps {
40+
// create a new application from the templatePath
41+
openshift.newApp(templatePath)
42+
}
43+
}
44+
stage('build') {
45+
steps {
46+
def builds = openshift.selector("bc", templateName).related('builds')
47+
// wait up to 5 minutes for the build to complete
48+
timeout(5) {
49+
builds.untilEach(1) {
50+
return (it.object().status.phase == "Complete")
51+
}
52+
}
53+
}
54+
}
55+
stage('deploy') {
56+
steps {
57+
def rm = openshift.selector("dc", templateName).rollout()
58+
// wait up to 5 minutes for the deployment to complete
59+
timeout(5) {
60+
openshift.selector("dc", templateName).related('pods').untilEach(1) {
61+
return (it.object().status.phase == "Running")
62+
}
63+
}
64+
}
65+
}
66+
stage('tag') {
67+
steps {
68+
// if everything else succeeded, tag the ${templateName}:latest image as ${templateName}-staging:latest
69+
// a pipeline build config for the staging environment can watch for the ${templateName}-staging:latest
70+
// image to change and then deploy it to the staging environment
71+
openshift.tag("${templateName}:latest", "${templateName}-staging:latest")
72+
}
73+
}
74+
}
75+
}
76+
}
77+
}
78+
type: JenkinsPipeline

pkg/oc/bootstrap/bindata.go

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/extended/testdata/bindata.go

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)