Skip to content

Commit 842f9d3

Browse files
Initial commit
1 parent d82eecd commit 842f9d3

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

Jenkinsfile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/groovy
2+
3+
@Library('github.com/fabric8io/fabric8-pipeline-library@master')
4+
def canaryVersion = "1.0.${env.BUILD_NUMBER}"
5+
def utils = new io.fabric8.Utils()
6+
def stashName = "buildpod.${env.JOB_NAME}.${env.BUILD_NUMBER}".replace('-', '_').replace('/', '_')
7+
def envStage = utils.environmentNamespace('stage')
8+
def envProd = utils.environmentNamespace('run')
9+
def setupScript = null
10+
11+
mavenNode {
12+
checkout scm
13+
if (utils.isCI()) {
14+
15+
mavenCI {
16+
integrationTestCmd =
17+
"mvn org.apache.maven.plugins:maven-failsafe-plugin:integration-test \
18+
org.apache.maven.plugins:maven-failsafe-plugin:verify \
19+
-Dnamespace.use.current=false -Dnamespace.use.existing=${utils.testNamespace()} \
20+
-Dit.test=*IT -DfailIfNoTests=false -DenableImageStreamDetection=true \
21+
-P openshift-it"
22+
}
23+
24+
} else if (utils.isCD()) {
25+
/*
26+
* Try to load the script ".openshiftio/Jenkinsfile.setup.groovy".
27+
* If it exists it must contain two functions named "setupEnvironmentPre()"
28+
* and "setupEnvironmentPost()" which should contain code that does any extra
29+
* required setup in OpenShift specific for the booster. The Pre version will
30+
* be called _before_ the booster objects are created while the Post version
31+
* will be called afterwards.
32+
*/
33+
try {
34+
setupScript = load "${pwd()}/.openshiftio/Jenkinsfile.setup.groovy"
35+
} catch (Exception ex) {
36+
echo "Jenkinsfile.setup.groovy not found"
37+
}
38+
39+
echo 'NOTE: running pipelines for the first time will take longer as build and base docker images are pulled onto the node'
40+
container(name: 'maven', shell:'/bin/bash') {
41+
stage('Build Image') {
42+
mavenCanaryRelease {
43+
version = canaryVersion
44+
}
45+
//stash deployment manifests
46+
stash includes: '**/*.yml', name: stashName
47+
}
48+
}
49+
}
50+
}
51+
52+
if (utils.isCD()) {
53+
node {
54+
stage('Rollout to Stage') {
55+
unstash stashName
56+
setupScript?.setupEnvironmentPre(envStage)
57+
apply {
58+
environment = envStage
59+
}
60+
setupScript?.setupEnvironmentPost(envStage)
61+
}
62+
63+
stage('Approve') {
64+
approve {
65+
room = null
66+
version = canaryVersion
67+
environment = 'Stage'
68+
}
69+
}
70+
71+
stage('Rollout to Run') {
72+
unstash stashName
73+
setupScript?.setupEnvironmentPre(envProd)
74+
apply {
75+
environment = envProd
76+
}
77+
setupScript?.setupEnvironmentPost(envProd)
78+
}
79+
}
80+
}
81+

0 commit comments

Comments
 (0)