Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding sample Jenkins Pipeline #16880

Merged
merged 1 commit into from
Oct 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.