Skip to content

Commit

Permalink
also adding shutdownCluster(cluster) inside a post { always {} } bloc…
Browse files Browse the repository at this point in the history
…k within each parallel stage to have post steps for each step
  • Loading branch information
ptankov committed Feb 4, 2025
1 parent 9250df5 commit 5f96dd7
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions cloud/jenkins/pso-eks.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,19 @@ void initTests() {
}

void clusterRunner(String cluster) {
def clusterCreated=0
def clusterCreated = false

for (int i=0; i<tests.size(); i++) {
if (tests[i]["result"] == "skipped") {
tests[i]["result"] = "failure"
tests[i]["cluster"] = cluster
if (clusterCreated == 0) {
if (!clusterCreated) {
createCluster(cluster)
clusterCreated++
clusterCreated = true
}
runTest(i)
}
}

if (clusterCreated >= 1) {
shutdownCluster(cluster)
}
}

void createCluster(String CLUSTER_SUFFIX) {
Expand Down Expand Up @@ -427,44 +423,40 @@ pipeline {
}
parallel {
stage('cluster1') {
agent {
label 'docker'
}
agent { label 'docker' }
steps {
prepareAgent()
unstash "sourceFILES"
clusterRunner('cluster1')
}
post { always { script { shutdownCluster('cluster1') } } }
}
stage('cluster2') {
agent {
label 'docker'
}
agent { label 'docker' }
steps {
prepareAgent()
unstash "sourceFILES"
clusterRunner('cluster2')
}
post { always { script { shutdownCluster('cluster2') } } }
}
stage('cluster3') {
agent {
label 'docker'
}
agent { label 'docker' }
steps {
prepareAgent()
unstash "sourceFILES"
clusterRunner('cluster3')
}
post { always { script { shutdownCluster('cluster3') } } }
}
stage('cluster4') {
agent {
label 'docker'
}
agent { label 'docker' }
steps {
prepareAgent()
unstash "sourceFILES"
clusterRunner('cluster4')
}
post { always { script { shutdownCluster('cluster4') } } }
}
}
}
Expand All @@ -480,8 +472,6 @@ pipeline {
if (currentBuild.result != null && currentBuild.result != 'SUCCESS') {
slackSend channel: '#cloud-dev-ci', color: '#FF0000', message: "[$JOB_NAME]: build $currentBuild.result, $BUILD_URL"
}

clusters.each { shutdownCluster(it) }
}

sh """
Expand Down

0 comments on commit 5f96dd7

Please sign in to comment.