forked from pegasystems/docker-pega-web-ready
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
64 lines (58 loc) · 2.34 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env groovy
def labels = ""
def imageName = ""
def artifactoryURL = "https://index.docker.io/v1/"
node("docker"){
stage("Initialize"){
currentBuild.displayName = "${env.BRANCH_NAME}-${env.BUILD_NUMBER}"
if (env.CHANGE_ID) {
//Just a comment
pullRequest.comment("Starting pipeline for PR validation -> ${env.BRANCH_NAME}-${env.BUILD_NUMBER}")
pullRequest.labels.each{
echo "label: $it"
validateProviderLabel(it)
labels += "$it,"
}
labels = labels.substring(0,labels.length()-1)
echo "PR labels -> $labels"
}else {
currentBuild.result = 'ABORTED'
throw new Exception("Aborting as this is not a PR job")
}
}
stage ("Checkout and Build Images") {
def scmVars = checkout scm
branchName = "${scmVars.GIT_BRANCH}"
withCredentials([string(credentialsId: 'automationuser', variable: 'AutomationDockerId')]) {
imageName = "${AutomationDockerId}/web-ready:${env.BRANCH_NAME}-${env.BUILD_NUMBER}"
withCredentials([usernamePassword(credentialsId: "automation_repo",
passwordVariable: 'ARTIFACTORY_PASSWORD', usernameVariable: 'ARTIFACTORY_USER')]) {
sh "docker login -u ${ARTIFACTORY_USER} -p ${ARTIFACTORY_PASSWORD} ${artifactoryURL}"
sh "docker build --no-cache -t ${imageName} ."
sh "docker push ${imageName}"
}
}
}
stage("Setup Cluster and Execute Tests") {
jobMap = [:]
jobMap["job"] = "../kubernetes-test-orchestrator/refactor"
jobMap["parameters"] = [
string(name: 'PROVIDERS', value: labels),
string(name: 'WEB_READY_IMAGE_NAME', value: imageName),
string(name: 'DOCKER_IMAGE_RESISTRY_URL', value: "${artifactoryURL}")
]
jobMap["propagate"] = true
jobMap["quietPeriod"] = 0
resultWrapper = build jobMap
currentBuild.result = resultWrapper.result
}
}
def validateProviderLabel(String provider){
def validProviders = ["integ-all","integ-eks","integ-gke","integ-aks"]
def failureMessage = "Invalid provider label - ${provider}. valid labels are ${validProviders}"
if(!validProviders.contains(provider)){
currentBuild.result = 'FAILURE'
pullRequest.comment("${failureMessage}")
throw new Exception("${failureMessage}")
}
}