Improved checking of already created stacks to deploy pipeline
Change-Id: I00db07193bb4c2c1fd39ba22106651e9f43975eb
diff --git a/lab-pipeline.groovy b/lab-pipeline.groovy
index b00c018..c488210 100644
--- a/lab-pipeline.groovy
+++ b/lab-pipeline.groovy
@@ -94,9 +94,11 @@
// Verify possibility of create stack for given user and stack type
//
wrap([$class: 'BuildUser']) {
- def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}", openstackEnv)
- if(existingStacks.size() > _MAX_PERMITTED_STACKS){
- throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}")
+ if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins")) {
+ def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}", openstackEnv)
+ if(existingStacks.size() >= _MAX_PERMITTED_STACKS){
+ throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}")
+ }
}
}
// launch stack