diff --git a/examples/jenkins/pipeline/nodejs-sample-pipeline.yaml b/examples/jenkins/pipeline/nodejs-sample-pipeline.yaml new file mode 100644 index 000000000000..f10cd7ec8066 --- /dev/null +++ b/examples/jenkins/pipeline/nodejs-sample-pipeline.yaml @@ -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 diff --git a/pkg/oc/bootstrap/bindata.go b/pkg/oc/bootstrap/bindata.go index ace1184df417..17cce2ff0efa 100644 --- a/pkg/oc/bootstrap/bindata.go +++ b/pkg/oc/bootstrap/bindata.go @@ -17,6 +17,7 @@ // examples/jenkins/pipeline/bluegreen-pipeline.yaml // examples/jenkins/pipeline/mapsapp-pipeline.yaml // examples/jenkins/pipeline/maven-pipeline.yaml +// examples/jenkins/pipeline/nodejs-sample-pipeline.yaml // examples/jenkins/pipeline/openshift-client-plugin-pipeline.yaml // examples/jenkins/pipeline/samplepipeline.yaml // examples/quickstarts/cakephp-mysql-persistent.json @@ -6233,6 +6234,101 @@ func examplesJenkinsPipelineMavenPipelineYaml() (*asset, error) { return a, nil } +var _examplesJenkinsPipelineNodejsSamplePipelineYaml = []byte(`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 +`) + +func examplesJenkinsPipelineNodejsSamplePipelineYamlBytes() ([]byte, error) { + return _examplesJenkinsPipelineNodejsSamplePipelineYaml, nil +} + +func examplesJenkinsPipelineNodejsSamplePipelineYaml() (*asset, error) { + bytes, err := examplesJenkinsPipelineNodejsSamplePipelineYamlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "examples/jenkins/pipeline/nodejs-sample-pipeline.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var _examplesJenkinsPipelineOpenshiftClientPluginPipelineYaml = []byte(`apiVersion: v1 kind: BuildConfig metadata: @@ -14553,6 +14649,7 @@ var _bindata = map[string]func() (*asset, error){ "examples/jenkins/pipeline/bluegreen-pipeline.yaml": examplesJenkinsPipelineBluegreenPipelineYaml, "examples/jenkins/pipeline/mapsapp-pipeline.yaml": examplesJenkinsPipelineMapsappPipelineYaml, "examples/jenkins/pipeline/maven-pipeline.yaml": examplesJenkinsPipelineMavenPipelineYaml, + "examples/jenkins/pipeline/nodejs-sample-pipeline.yaml": examplesJenkinsPipelineNodejsSamplePipelineYaml, "examples/jenkins/pipeline/openshift-client-plugin-pipeline.yaml": examplesJenkinsPipelineOpenshiftClientPluginPipelineYaml, "examples/jenkins/pipeline/samplepipeline.yaml": examplesJenkinsPipelineSamplepipelineYaml, "examples/quickstarts/cakephp-mysql-persistent.json": examplesQuickstartsCakephpMysqlPersistentJson, @@ -14645,6 +14742,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "bluegreen-pipeline.yaml": &bintree{examplesJenkinsPipelineBluegreenPipelineYaml, map[string]*bintree{}}, "mapsapp-pipeline.yaml": &bintree{examplesJenkinsPipelineMapsappPipelineYaml, map[string]*bintree{}}, "maven-pipeline.yaml": &bintree{examplesJenkinsPipelineMavenPipelineYaml, map[string]*bintree{}}, + "nodejs-sample-pipeline.yaml": &bintree{examplesJenkinsPipelineNodejsSamplePipelineYaml, map[string]*bintree{}}, "openshift-client-plugin-pipeline.yaml": &bintree{examplesJenkinsPipelineOpenshiftClientPluginPipelineYaml, map[string]*bintree{}}, "samplepipeline.yaml": &bintree{examplesJenkinsPipelineSamplepipelineYaml, map[string]*bintree{}}, }}, diff --git a/test/extended/testdata/bindata.go b/test/extended/testdata/bindata.go index 00a0e5850e6e..2b8cc746f093 100644 --- a/test/extended/testdata/bindata.go +++ b/test/extended/testdata/bindata.go @@ -237,6 +237,7 @@ // examples/jenkins/pipeline/bluegreen-pipeline.yaml // examples/jenkins/pipeline/mapsapp-pipeline.yaml // examples/jenkins/pipeline/maven-pipeline.yaml +// examples/jenkins/pipeline/nodejs-sample-pipeline.yaml // examples/jenkins/pipeline/openshift-client-plugin-pipeline.yaml // examples/jenkins/pipeline/samplepipeline.yaml // examples/quickstarts/cakephp-mysql.json @@ -26968,6 +26969,101 @@ func examplesJenkinsPipelineMavenPipelineYaml() (*asset, error) { return a, nil } +var _examplesJenkinsPipelineNodejsSamplePipelineYaml = []byte(`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 +`) + +func examplesJenkinsPipelineNodejsSamplePipelineYamlBytes() ([]byte, error) { + return _examplesJenkinsPipelineNodejsSamplePipelineYaml, nil +} + +func examplesJenkinsPipelineNodejsSamplePipelineYaml() (*asset, error) { + bytes, err := examplesJenkinsPipelineNodejsSamplePipelineYamlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "examples/jenkins/pipeline/nodejs-sample-pipeline.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var _examplesJenkinsPipelineOpenshiftClientPluginPipelineYaml = []byte(`apiVersion: v1 kind: BuildConfig metadata: @@ -28537,6 +28633,7 @@ var _bindata = map[string]func() (*asset, error){ "examples/jenkins/pipeline/bluegreen-pipeline.yaml": examplesJenkinsPipelineBluegreenPipelineYaml, "examples/jenkins/pipeline/mapsapp-pipeline.yaml": examplesJenkinsPipelineMapsappPipelineYaml, "examples/jenkins/pipeline/maven-pipeline.yaml": examplesJenkinsPipelineMavenPipelineYaml, + "examples/jenkins/pipeline/nodejs-sample-pipeline.yaml": examplesJenkinsPipelineNodejsSamplePipelineYaml, "examples/jenkins/pipeline/openshift-client-plugin-pipeline.yaml": examplesJenkinsPipelineOpenshiftClientPluginPipelineYaml, "examples/jenkins/pipeline/samplepipeline.yaml": examplesJenkinsPipelineSamplepipelineYaml, "examples/quickstarts/cakephp-mysql.json/cakephp-mysql.json": examplesQuickstartsCakephpMysqlJsonCakephpMysqlJson, @@ -28616,6 +28713,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "bluegreen-pipeline.yaml": &bintree{examplesJenkinsPipelineBluegreenPipelineYaml, map[string]*bintree{}}, "mapsapp-pipeline.yaml": &bintree{examplesJenkinsPipelineMapsappPipelineYaml, map[string]*bintree{}}, "maven-pipeline.yaml": &bintree{examplesJenkinsPipelineMavenPipelineYaml, map[string]*bintree{}}, + "nodejs-sample-pipeline.yaml": &bintree{examplesJenkinsPipelineNodejsSamplePipelineYaml, map[string]*bintree{}}, "openshift-client-plugin-pipeline.yaml": &bintree{examplesJenkinsPipelineOpenshiftClientPluginPipelineYaml, map[string]*bintree{}}, "samplepipeline.yaml": &bintree{examplesJenkinsPipelineSamplepipelineYaml, map[string]*bintree{}}, }},