diff --git a/Jenkinsfile b/Jenkinsfile index d85be1d..fc1d34d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { parameters { string(name: 'CLUSTER', defaultValue: '', description: 'Enter the cluster name') choice(name: 'ENVIRONMENT', choices: ['euprod', 'eupreprod', 'napreprod', 'naprod', 'cnprod', 'cnpreprod'], description: 'Choose Dynatrace environment') - string(name: 'OWNER', defaultValue: '', description: 'Enter e-mail address of dashboard owner') + string(name: 'OWNER', defaultValue: '', description: 'Enter e-mail address of dashboard owner. Optional if REMOVE parameter is set to true') booleanParam(name: 'REMOVE', defaultValue: false, description: 'Check if dashboard for provided cluster should be removed instead of created') } @@ -47,15 +47,16 @@ pipeline { steps { script { def SCRIPT_PARAMETER = '' - if(CLUSTER.isEmpty()) { + if(CLUSTER.isEmpty() || ENVIRONMENT.isEmpty()) { currentBuild.result = 'ABORTED' - error('Aborting due to missing CLUSTER parameter') + error('Aborting due to missing CLUSTER or ENVIRONMENT parameters') return } - else if(ENVIRONMENT.isEmpty()) { - currentBuild.result = 'ABORTED' - error('Aborting due to missing ENVIRONMENT parameter') - return + else if(REMOVE.toBoolean()) { + SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -C " + CLUSTER.toString() + SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -E " + ENVIRONMENT.toString() + SCRIPT_PARAMETER = SCRIPT_PARAMETER + " --remove " + sh "python createDash.py ${SCRIPT_PARAMETER}" } else if(OWNER.isEmpty()) { currentBuild.result = 'ABORTED' @@ -66,7 +67,6 @@ pipeline { SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -C " + CLUSTER.toString() SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -E " + ENVIRONMENT.toString() SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -O " + OWNER.toString() - if(REMOVE.toBoolean()) { SCRIPT_PARAMETER = SCRIPT_PARAMETER + " --remove "} sh "python createDash.py ${SCRIPT_PARAMETER}" } }