configpolicy/vars/applyConfigPolicy.groovy

70 lines
1.5 KiB
Groovy

def call(rw_pattern, stages) {
properties([
pipelineTriggers([cron('H H * * *')])
])
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()
}
}
}
}
}
}
}
def stageKinit() {
stage('kinit') {
echo 'kinit'
}
}
def stageRemountRW(rw_pattern) {
stage('Remount R/W') {
echo 'Remount R/W'
}
}
def generateStages(stages) {
stages.each { name, playbooks ->
stage(name) {
playbooks.each { playbook ->
echo playbook
}
}
}
}
def stageRemountRO(rw_pattern) {
stage('Remount R/O') {
echo 'Remount R/O'
}
}
def postCleanup() {
echo 'Cleanup'
}
def postFailure(err) {
currentBuild.result = 'FAILURE'
echo "${err}"
}