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

Commit

Permalink
Add skip cleanup option to e2e test pipeline
Browse files Browse the repository at this point in the history
Add option for skipping the cleanup of a job in case
of failure and resume it later for compleating the
cleanup.

Signed-off-by: Pablo Chacin <pchacin@suse.com>
  • Loading branch information
Pablo Chacin committed Jul 1, 2020
1 parent 4a20e4c commit ac4b04e
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions ci/jenkins/pipelines/skuba-e2e-test.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def original_registry = ""
// worker selection labels
def labels = 'e2e'

// control cleanup in case of failure
def skip_cleanup = true

node('caasp-team-private-integration') {
stage('select worker') {
if (env.BRANCH != 'master') {
Expand Down Expand Up @@ -45,7 +48,8 @@ pipeline {
agent { node { label "caasp-team-private-${worker_type} && ${labels}" } }

environment {
SKUBA_BINPATH = "/home/jenkins/go/bin/skuba"
GOPATH = "${WORSPACE}/go"
SKUBA_BINPATH = "${GOPATH}/bin/skuba"
OPENSTACK_OPENRC = credentials('ecp-openrc')
GITHUB_TOKEN = credentials('github-token')
VMWARE_ENV_FILE = credentials('vmware-env')
Expand All @@ -56,9 +60,10 @@ pipeline {
}

stages {
stage('Getting Ready For Cluster Deployment') { steps {
stage('Pre Deployment') { steps {
sh(script: "make -f ci/Makefile pre_deployment", label: 'Pre Deployment')
sh(script: "make -f Makefile install", label: 'Build Skuba')
sh(script: "mkdir -p ${WORKSPACE}/go/bin")
sh(script: "make install", label: 'Build Skuba')
} }

stage('Provision cluster') {
Expand Down Expand Up @@ -89,21 +94,30 @@ pipeline {
sh(script: "make --keep-going -f ci/Makefile gather_logs", label: 'Gather Logs')
archiveArtifacts(artifacts: 'platform_logs/**/*', allowEmptyArchive: true)
}
cleanup {
sh(script: "make --keep-going -f ci/Makefile cleanup", label: 'Cleanup')
dir("${WORKSPACE}@tmp") {
deleteDir()
}
dir("${WORKSPACE}@script") {
deleteDir()
}
dir("${WORKSPACE}@script@tmp") {
deleteDir()
failure{ script {
if (skip_cleanup) {
stash(name: 'workspace', include:'ci/**,go/bin/')
}
}}
cleanup { script {
if (!skip_cleanup) {
sh(script: "make --keep-going -f ci/Makefile cleanup", label: 'Cleanup')
dir("${WORKSPACE}") {
deleteDir()
}
return
}
dir("${WORKSPACE}") {
deleteDir()
}
sh(script: "rm -f ${SKUBA_BINPATH}; ", label: 'Remove built skuba')
}
}}
}
}

// this stage is executed only if skip cleanup is requested
node("caasp-team-private-${worker_type} && ${labels}") {
stage('cleanup') {steps {
upstash 'workspace'
sh(script: "make --keep-going -f ci/Makefile cleanup", label: 'Cleanup')
dir("${WORKSPACE}") {
deleteDir()
}
}}
}

0 comments on commit ac4b04e

Please sign in to comment.