Allow to set custom STACK_NAME when creating infra

This patch allows to create custom STACK_NAME when crating infra but
user-id will still be added to make sure we save check for max allowed
stack per user.

This is needed to avoid issues when paren job is terminated, and cleanup
failed because stack-name is not available to parent job at this time.

Change-Id: I834cfc22ad631d71b3af4587195192dd38e400ac
Related-Prod: PROD-19102
diff --git a/cloud-deploy-pipeline.groovy b/cloud-deploy-pipeline.groovy
index f05735a..eb9cc8e 100644
--- a/cloud-deploy-pipeline.groovy
+++ b/cloud-deploy-pipeline.groovy
@@ -134,12 +134,19 @@
                     }
 
                     if (STACK_REUSE.toBoolean() == false) {
-                        // Don't allow to set custom heat stack name
+                        // TODO(vsaienko): remove stack creation from this pipeline to separate job
+                        // Allow to set custom stack name but user-id will be added anyway
+                        // This will fix issue with cleanup when job is aborted by jenkins and
+                        // still guarantee stack count per user.
+                        def stackNameSuffix = "${JOB_NAME}-${BUILD_NUMBER}"
+                        if (STACK_NAME != ''){
+                          stackNameSuffix = STACK_NAME
+                        }
                         wrap([$class: 'BuildUser']) {
                             if (env.BUILD_USER_ID) {
-                                STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
+                                STACK_NAME = "${env.BUILD_USER_ID}-${stackNameSuffix}"
                             } else {
-                                STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
+                                STACK_NAME = "jenkins-${stackNameSuffix}"
                             }
                             currentBuild.description = STACK_NAME
                         }