Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

Commit 0b23291

Browse files
committed
Deploy plannerUI snapshot
Added new groovy script for building and deploying plannerUI standalone snapshot in CI.
1 parent 4b899c6 commit 0b23291

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

vars/deployPlannerSnapshot.groovy

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/groovy
2+
3+
import java.util.regex.Pattern
4+
5+
def call(body) {
6+
// evaluate the body block, and collect configuration into the object
7+
def config = [:]
8+
body.resolveStrategy = Closure.DELEGATE_FIRST
9+
body.delegate = config
10+
body()
11+
12+
def yaml
13+
def openShiftProject = config.openShiftProject
14+
def openShiftTemplate = config.openShiftTemplate
15+
def originalImageName = config.originalImageName
16+
def newImageName = config.newImageName
17+
def deploymentName = config.githubRepo
18+
def providerLabel = config.providerLabel ?: 'fabric8'
19+
def project = config.githubProject
20+
21+
def flow = new io.fabric8.Fabric8Commands()
22+
def utils = new io.fabric8.Utils()
23+
24+
openShiftProject = openShiftProject + '-' + utils.getRepoName()
25+
container('clients') {
26+
if (!flow.isAuthorCollaborator("", project)){
27+
currentBuild.result = 'ABORTED'
28+
error 'Change author is not a collaborator on the project, aborting build until we support the [test] comment'
29+
}
30+
31+
yaml = flow.getUrlAsString(openShiftTemplate)
32+
yaml = Pattern.compile("- image: ${originalImageName}:(.*)").matcher(yaml).replaceFirst("- image: ${newImageName}")
33+
34+
if (!yaml.contains(newImageName)){
35+
error "original image ${originalImageName} not replaced with ${newImageName} in yaml: \n ${yaml}"
36+
}
37+
}
38+
// cant use writeFile as we have long filename errors
39+
sh "echo '${yaml}' > snapshot.yml"
40+
41+
container('clients') {
42+
try {
43+
sh "oc get project ${openShiftProject} | grep Active"
44+
} catch (err) {
45+
echo "${err}"
46+
sh "oc new-project ${openShiftProject}"
47+
}
48+
49+
sh "oc process -n ${openShiftProject} -f ./snapshot.yml | oc apply -n ${openShiftProject} -f -"
50+
51+
sleep 10
52+
// ok bad bad but there's a delay between DC's being applied and new pods being started. lets find a better way to do this looking at teh new DC perhaps?
53+
54+
waitUntil {
55+
// wait until the pods are running has been deleted
56+
try {
57+
sh "oc get pod -l app=${deploymentName},provider=${providerLabel} -n ${openShiftProject} | grep Running"
58+
echo "${deploymentName} pod is running"
59+
return true
60+
} catch (err) {
61+
echo "waiting for ${deploymentName} to be ready..."
62+
return false
63+
}
64+
}
65+
return sh(script: "oc get route ${deploymentName} -o jsonpath=\"{.spec.host}\" -n ${openShiftProject}", returnStdout: true).toString().trim()
66+
}
67+
}

0 commit comments

Comments
 (0)