diff --git a/vars/applyConfigPolicy.groovy b/vars/applyConfigPolicy.groovy index d134996..c16c15d 100644 --- a/vars/applyConfigPolicy.groovy +++ b/vars/applyConfigPolicy.groovy @@ -1,4 +1,5 @@ import groovy.transform.Field +import org.jenkinsci.plugins.pipeline.modeldefinition.Utils @Field def DOCKER_ARGS = '''\ @@ -52,15 +53,20 @@ def stageKinit() { def stageRemountRW(limit) { - stage('Remount R/W') { - ansiblePlaybook \ - playbook: 'remount.yml', - limit: limit, - become: true, - vaultCredentialsId: 'ansible-vault', - extraVars: [ - remount_state: 'rw', - ] + def STAGE_NAME = 'Remount R/W' + stage(STAGE_NAME) { + if (limit) { + ansiblePlaybook \ + playbook: 'remount.yml', + limit: limit, + become: true, + vaultCredentialsId: 'ansible-vault', + extraVars: [ + remount_state: 'rw', + ] + } else { + Utils.markStageSkippedForConditional(STAGE_NAME) + } } } @@ -80,13 +86,18 @@ def generateStages(stages) { } def stageRemountRO(limit) { - stage('Remount R/O') { - ansiblePlaybook \ - playbook: 'remount.yml', - limit: limit + ':!rw-root', - become: true, - vaultCredentialsId: 'ansible-vault', - extras: '--diff' + def STAGE_NAME = 'Remount R/W' + stage(STAGE_NAME) { + if (limit) { + ansiblePlaybook \ + playbook: 'remount.yml', + limit: limit + ':!rw-root', + become: true, + vaultCredentialsId: 'ansible-vault', + extras: '--diff' + } else { + Utils.markStageSkippedForConditional(STAGE_NAME) + } } }