From 1549d745984826c5230ed2ea70783fddcebe03a2 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Mon, 16 Mar 2020 21:04:25 -0500 Subject: [PATCH] draft: applyConfigPolicy --- vars/applyConfigPolicy.groovy | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 vars/applyConfigPolicy.groovy diff --git a/vars/applyConfigPolicy.groovy b/vars/applyConfigPolicy.groovy new file mode 100644 index 0000000..edb8795 --- /dev/null +++ b/vars/applyConfigPolicy.groovy @@ -0,0 +1,64 @@ +def call(rw_pattern, stages) { + timeout(time: 1, unit: 'HOURS') { + lock('cfgpol') { + node { + checkout scm + def image = docker.build( + "configpolicy:${env.BRANCH_NAME}", + 'ci', + ) + image.inside { + withEnv(["KRB5CCNAME=${WORKSPACE}/.krb5cc"]) { + stageKinit() + try { + stageRemountRW(rw_pattern) + generateStages(stages) + stageRemountRO(rw_pattern) + } catch (err) { + postFailure(err) + } finally { + postCleanup() + } + } + } + } + } + } +} + +stageKinit() { + stage('kinit') { + echo 'kinit' + } +} + + +stageRemountRW(rw_pattern) { + stage('Remount R/W') { + echo 'Remount R/W' + } +} + +generateStages(stages) { + stages.each { name, playbooks -> + stage(name) { + playbooks.each { playbook -> + echo playbook + } + } + } +} + +stageRemountRO(rw_pattern) { + echo 'Remount R/O' +} + + +postCleanup() { + echo 'Cleanup' +} + +postFailure(err) { + currentBuild.result = 'FAILURE' + echo "${err}" +}