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

Add option for skipping cleanup to e2e test pipeline #1219

Merged
merged 2 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions ci/jenkins/pipelines/skuba-e2e-test.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ def original_registry = ""
// worker selection labels
def labels = 'e2e'

// keep the cluster at the end of the job
def keep_cluster = false

node('caasp-team-private-integration') {
stage('select worker') {

if (env.BRANCH != 'master') {
if (env.BRANCH.startsWith('experimental') || env.BRANCH.startsWith('maintenance')) {
worker_type = env.BRANCH
Expand All @@ -33,6 +37,10 @@ node('caasp-team-private-integration') {
labels = env.WORKER_LABELS
}

if (env.RETAIN_CLUSTER){
labels = labels + "&& dedicated"
}

if (env.REPO_BRANCH){
branch_repo = "http://download.suse.de/ibs/Devel:/CaaSP:/5:/Branches:/${env.REPO_BRANCH}/SLE_15_SP2"
branch_registry = "registry.suse.de/devel/caasp/5/branches/${env.REPO_BRANCH}/containers"
Expand Down Expand Up @@ -93,8 +101,26 @@ pipeline {
archiveArtifacts(artifacts: 'platform_logs/**/*', allowEmptyArchive: true)
}
}}
cleanup {
sh(script: "make --keep-going -f ci/Makefile cleanup", label: 'Cleanup')
failure{ script{
if (env.RETAIN_CLUSTER) {
def retention_period= env.RETENTION_PERIOD?env.RETENTION_PERIOD:24
try{
timeout(time: retention_period, unit: 'HOURS'){
input(message: 'Waiting '+retention_period +' hours before cleaning up cluster \n. ' +
'Press <abort> to cleanup inmediately, <keep> for keeping it',
ok: 'keep')
keep_cluster = true
}
}catch (err){
// either timeout occurred or <abort> was selected
keep_cluster = false
}
}
}}
cleanup{ script{
if(!keep_cluster){
sh(script: "make --keep-going -f ci/Makefile cleanup", label: 'Cleanup')
}
dir("${WORKSPACE}@tmp") {
deleteDir()
}
Expand All @@ -108,6 +134,6 @@ pipeline {
deleteDir()
}
sh(script: "rm -f ${SKUBA_BINPATH}; ", label: 'Remove built skuba')
}
}}
}
}
13 changes: 9 additions & 4 deletions ci/jenkins/templates/e2e-dev-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
project-type: pipeline
number-to-keep: 30
days-to-keep: 30
wrappers:
- timeout:
timeout: 120
fail: true
concurrent: true
parameters:
- string:
name: BRANCH
Expand All @@ -16,6 +13,14 @@
name: PLATFORM
default: 'vmware'
description: The platform to perform the tests on
- bool:
name: RETAIN_CLUSTER
default: false
description: Retain the cluster in case of failure
- string:
name: RETENTION_PERIOD
default: 24
description: retention period for cluster (in hours)
- string:
name: E2E_MAKE_TARGET_NAME
default: ''
Expand Down