-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16880 from coreydaley/trello_1148_jenkins_pipelin…
…e_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
- Loading branch information
Showing
3 changed files
with
274 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
kind: "BuildConfig" | ||
apiVersion: "v1" | ||
metadata: | ||
name: "nodejs-sample-pipeline" | ||
spec: | ||
strategy: | ||
jenkinsPipelineStrategy: | ||
jenkinsfile: |- | ||
// path of the template to use | ||
def templatePath = 'https://raw.githubusercontent.com/openshift/nodejs-ex/master/openshift/templates/nodejs-mongodb.json' | ||
// name of the template that will be created | ||
def templateName = 'nodejs-mongodb-example' | ||
openshift.withCluster() { | ||
openshift.withProject() { | ||
echo "Using project: ${openshift.project()}" | ||
pipeline { | ||
agent { | ||
node { | ||
// spin up a node.js slave pod to run this build on | ||
label 'nodejs' | ||
} | ||
} | ||
options { | ||
// set a timeout of 20 minutes for this pipeline | ||
timeout(time: 20, unit: 'MINUTES') | ||
} | ||
stages { | ||
stage('cleanup') { | ||
steps { | ||
// delete everything with this template label | ||
openshift.selector("all", [ template : templateName ]).delete() | ||
// delete any secrets with this template label | ||
if (openshift.selector("secrets", templateName).exists()) { | ||
openshift.selector("secrets", templateName).delete() | ||
} | ||
} | ||
} | ||
stage('create') { | ||
steps { | ||
// create a new application from the templatePath | ||
openshift.newApp(templatePath) | ||
} | ||
} | ||
stage('build') { | ||
steps { | ||
def builds = openshift.selector("bc", templateName).related('builds') | ||
// wait up to 5 minutes for the build to complete | ||
timeout(5) { | ||
builds.untilEach(1) { | ||
return (it.object().status.phase == "Complete") | ||
} | ||
} | ||
} | ||
} | ||
stage('deploy') { | ||
steps { | ||
def rm = openshift.selector("dc", templateName).rollout() | ||
// wait up to 5 minutes for the deployment to complete | ||
timeout(5) { | ||
openshift.selector("dc", templateName).related('pods').untilEach(1) { | ||
return (it.object().status.phase == "Running") | ||
} | ||
} | ||
} | ||
} | ||
stage('tag') { | ||
steps { | ||
// if everything else succeeded, tag the ${templateName}:latest image as ${templateName}-staging:latest | ||
// a pipeline build config for the staging environment can watch for the ${templateName}-staging:latest | ||
// image to change and then deploy it to the staging environment | ||
openshift.tag("${templateName}:latest", "${templateName}-staging:latest") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
type: JenkinsPipeline |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.