diff --git a/maven/Release/Jenkinsfile b/maven/Release/Jenkinsfile index 9ad70e3..eac6562 100644 --- a/maven/Release/Jenkinsfile +++ b/maven/Release/Jenkinsfile @@ -1,31 +1,23 @@ -#!/usr/bin/groovy +@Library('github.com/fabric8io/osio-pipeline@master') _ -@Library('github.com/fabric8io/fabric8-pipeline-library@master') -def canaryVersion = "1.0.${env.BUILD_NUMBER}" -def utils = new io.fabric8.Utils() +osio { -mavenNode { - checkout scm - if (utils.isCI()) { + config runtime: 'java', version: '1.8' - mavenCI { - integrationTestCmd = - "mvn org.apache.maven.plugins:maven-failsafe-plugin:integration-test \ - org.apache.maven.plugins:maven-failsafe-plugin:verify \ - -Dnamespace.use.current=false -Dnamespace.use.existing=${utils.testNamespace()} \ - -Dit.test=*IT -DfailIfNoTests=false -DenableImageStreamDetection=true \ - -P openshift-it" - } + ci { - } else if (utils.isCD()) { - echo 'NOTE: running pipelines for the first time will take longer as build and base docker images are pulled onto the node' - container(name: 'maven', shell:'/bin/bash') { - stage('Build Image') { - mavenCanaryRelease { - version = canaryVersion - } - } - } + testCmd = "mvn test -Popenshift" + spawn image: "java", version: "1.8", commands: testCmd, stage: "CI test" } -} + cd { + + // processing openshift template present in .openshiftio/application.yaml + def resources = processTemplate(params: [ + RELEASE_VERSION: "1.0.${env.BUILD_NUMBER}" + ]) + + // performs an s2i build + build resources: resources + } +} diff --git a/maven/ReleaseAndStage/Jenkinsfile b/maven/ReleaseAndStage/Jenkinsfile index 329701b..c7c1985 100644 --- a/maven/ReleaseAndStage/Jenkinsfile +++ b/maven/ReleaseAndStage/Jenkinsfile @@ -1,64 +1,25 @@ -#!/usr/bin/groovy +@Library('github.com/fabric8io/osio-pipeline@master') _ -@Library('github.com/fabric8io/fabric8-pipeline-library@master') -def canaryVersion = "1.0.${env.BUILD_NUMBER}" -def utils = new io.fabric8.Utils() -def stashName = "buildpod.${env.JOB_NAME}.${env.BUILD_NUMBER}".replace('-', '_').replace('/', '_') -def envStage = utils.environmentNamespace('stage') -def envProd = utils.environmentNamespace('run') -def setupScript = null +osio { -mavenNode { - checkout scm - if (utils.isCI()) { + config runtime: 'java', version: '1.8' - mavenCI { - integrationTestCmd = - "mvn org.apache.maven.plugins:maven-failsafe-plugin:integration-test \ - org.apache.maven.plugins:maven-failsafe-plugin:verify \ - -Dnamespace.use.current=false -Dnamespace.use.existing=${utils.testNamespace()} \ - -Dit.test=*IT -DfailIfNoTests=false -DenableImageStreamDetection=true \ - -P openshift-it" - } + ci { - } else if (utils.isCD()) { - /* - * Try to load the script ".openshiftio/Jenkinsfile.setup.groovy". - * If it exists it must contain two functions named "setupEnvironmentPre()" - * and "setupEnvironmentPost()" which should contain code that does any extra - * required setup in OpenShift specific for the booster. The Pre version will - * be called _before_ the booster objects are created while the Post version - * will be called afterwards. - */ - try { - setupScript = load "${pwd()}/.openshiftio/Jenkinsfile.setup.groovy" - } catch (Exception ex) { - echo "Jenkinsfile.setup.groovy not found" - } - - echo 'NOTE: running pipelines for the first time will take longer as build and base docker images are pulled onto the node' - container(name: 'maven', shell:'/bin/bash') { - stage('Build Image') { - mavenCanaryRelease { - version = canaryVersion - } - //stash deployment manifests - stash includes: '**/*.yml', name: stashName - } - } + testCmd = "mvn test -Popenshift" + spawn image: "java", version: "1.8", commands: testCmd, stage: "CI test" } -} -if (utils.isCD()) { - node { - stage('Rollout to Stage') { - unstash stashName - setupScript?.setupEnvironmentPre(envStage) - apply { - environment = envStage - } - setupScript?.setupEnvironmentPost(envStage) - } + cd { + + // processing openshift template present in .openshiftio/application.yaml + def resources = processTemplate(params: [ + RELEASE_VERSION: "1.0.${env.BUILD_NUMBER}" + ]) + + // performs an s2i build + build resources: resources + // deploy to stage environment + deploy resources: resources, env: 'stage' } } - diff --git a/maven/ReleaseAndStage/metadata.yml b/maven/ReleaseAndStage/metadata.yml index 69ae3e5..c41de5f 100644 --- a/maven/ReleaseAndStage/metadata.yml +++ b/maven/ReleaseAndStage/metadata.yml @@ -7,5 +7,4 @@ stages: - name: Build Image description: creates a new version and then builds the image - name: Rollout to Stage - description: stages the new version into the Stage environment - \ No newline at end of file + description: stages the new version into the Stage environment diff --git a/maven/ReleaseStageApproveAndPromote/Jenkinsfile b/maven/ReleaseStageApproveAndPromote/Jenkinsfile index c07bb52..543015f 100644 --- a/maven/ReleaseStageApproveAndPromote/Jenkinsfile +++ b/maven/ReleaseStageApproveAndPromote/Jenkinsfile @@ -1,81 +1,28 @@ -#!/usr/bin/groovy +@Library('github.com/fabric8io/osio-pipeline@master') _ -@Library('github.com/fabric8io/fabric8-pipeline-library@master') -def canaryVersion = "1.0.${env.BUILD_NUMBER}" -def utils = new io.fabric8.Utils() -def stashName = "buildpod.${env.JOB_NAME}.${env.BUILD_NUMBER}".replace('-', '_').replace('/', '_') -def envStage = utils.environmentNamespace('stage') -def envProd = utils.environmentNamespace('run') -def setupScript = null +osio { -mavenNode { - checkout scm - if (utils.isCI()) { + config runtime: 'java', version: '1.8' - mavenCI { - integrationTestCmd = - "mvn org.apache.maven.plugins:maven-failsafe-plugin:integration-test \ - org.apache.maven.plugins:maven-failsafe-plugin:verify \ - -Dnamespace.use.current=false -Dnamespace.use.existing=${utils.testNamespace()} \ - -Dit.test=*IT -DfailIfNoTests=false -DenableImageStreamDetection=true \ - -P openshift-it" - } + ci { - } else if (utils.isCD()) { - /* - * Try to load the script ".openshiftio/Jenkinsfile.setup.groovy". - * If it exists it must contain two functions named "setupEnvironmentPre()" - * and "setupEnvironmentPost()" which should contain code that does any extra - * required setup in OpenShift specific for the booster. The Pre version will - * be called _before_ the booster objects are created while the Post version - * will be called afterwards. - */ - try { - setupScript = load "${pwd()}/.openshiftio/Jenkinsfile.setup.groovy" - } catch (Exception ex) { - echo "Jenkinsfile.setup.groovy not found" - } - - echo 'NOTE: running pipelines for the first time will take longer as build and base docker images are pulled onto the node' - container(name: 'maven', shell:'/bin/bash') { - stage('Build Image') { - mavenCanaryRelease { - version = canaryVersion - } - //stash deployment manifests - stash includes: '**/*.yml', name: stashName - } - } + testCmd = "mvn test -Popenshift" + spawn image: "java", version: "1.8", commands: testCmd, stage: "CI test" } -} -if (utils.isCD()) { - node { - stage('Rollout to Stage') { - unstash stashName - setupScript?.setupEnvironmentPre(envStage) - apply { - environment = envStage - } - setupScript?.setupEnvironmentPost(envStage) - } + cd { - stage('Approve') { - approve { - room = null - version = canaryVersion - environment = 'Stage' - } - } + // processing openshift template present in .openshiftio/application.yaml + def resources = processTemplate(params: [ + RELEASE_VERSION: "1.0.${env.BUILD_NUMBER}" + ]) + + // performs an s2i build + build resources: resources + // deploy to stage environment + deploy resources: resources, env: 'stage' + // wait for user to approve the promotion to "run" environment + deploy resources: resources, env: 'run', approval: 'manual' - stage('Rollout to Run') { - unstash stashName - setupScript?.setupEnvironmentPre(envProd) - apply { - environment = envProd - } - setupScript?.setupEnvironmentPost(envProd) - } } } - diff --git a/maven/ReleaseStageApproveAndPromote/metadata.yml b/maven/ReleaseStageApproveAndPromote/metadata.yml index 9fa3133..23d31d8 100644 --- a/maven/ReleaseStageApproveAndPromote/metadata.yml +++ b/maven/ReleaseStageApproveAndPromote/metadata.yml @@ -10,7 +10,6 @@ stages: - name: Rollout to Stage description: stages the new version into the Stage environment - name: Approve - description: waits for Approval to promote + description: waits for Approval to promote - name: Rollout to Run - description: promotes to the Run environment - \ No newline at end of file + description: promotes to the Run environment