Skip to content

Commit

Permalink
Merge pull request #16880 from coreydaley/trello_1148_jenkins_pipelin…
Browse files Browse the repository at this point in the history
…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
openshift-merge-robot authored Oct 27, 2017
2 parents eecb026 + 2d1bea7 commit 0f1a868
Show file tree
Hide file tree
Showing 3 changed files with 274 additions and 0 deletions.
78 changes: 78 additions & 0 deletions examples/jenkins/pipeline/nodejs-sample-pipeline.yaml
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
98 changes: 98 additions & 0 deletions pkg/oc/bootstrap/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 98 additions & 0 deletions test/extended/testdata/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0f1a868

Please sign in to comment.