forked from fabric8io/fabric8-jenkinsfile-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modifying Jenkifiles to support the osio pipeline library
- Loading branch information
1 parent
d63a62a
commit 12d9d94
Showing
5 changed files
with
55 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} | ||
integrationTestCmd = "mvn verify integration-test -Dnamespace.use.current=false -Dnamespace.use.existing=${testNamespace()} -Dit.test=*IT -DfailIfNoTests=false -DenableImageStreamDetection=true -Popenshift,openshift-it" | ||
runTest commands: integrationTestCmd | ||
} | ||
} | ||
|
||
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
integrationTestCmd = "mvn verify integration-test -Dnamespace.use.current=false -Dnamespace.use.existing=${testNamespace()} -Dit.test=*IT -DfailIfNoTests=false -DenableImageStreamDetection=true -Popenshift,openshift-it" | ||
runTest commands: integrationTestCmd | ||
} | ||
} | ||
|
||
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' | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
integrationTestCmd = "mvn verify integration-test -Dnamespace.use.current=false -Dnamespace.use.existing=${testNamespace()} -Dit.test=*IT -DfailIfNoTests=false -DenableImageStreamDetection=true -Popenshift,openshift-it" | ||
runTest commands: integrationTestCmd | ||
} | ||
} | ||
|
||
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) | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters