Skip to content
Open
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
42 changes: 17 additions & 25 deletions maven/Release/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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
}
}
73 changes: 17 additions & 56 deletions maven/ReleaseAndStage/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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'
}
}

3 changes: 1 addition & 2 deletions maven/ReleaseAndStage/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

description: stages the new version into the Stage environment
89 changes: 18 additions & 71 deletions maven/ReleaseStageApproveAndPromote/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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)
}
}
}

5 changes: 2 additions & 3 deletions maven/ReleaseStageApproveAndPromote/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

description: promotes to the Run environment