Saving to Artifactory should be optional

PROD-36431

Change-Id: I6084cac4dc34dca27192eed279b97e9fd94b190b
diff --git a/generate-cookiecutter-products.groovy b/generate-cookiecutter-products.groovy
index 98107b8..4eb511c 100644
--- a/generate-cookiecutter-products.groovy
+++ b/generate-cookiecutter-products.groovy
@@ -20,6 +20,7 @@
 slaveNode = env.getProperty('SLAVE_NODE') ?: 'virtual'
 gerritCredentials = env.getProperty('CREDENTIALS_ID') ?: 'gerrit'
 runTestModel = (env.getProperty('TEST_MODEL') ?: true).toBoolean()
+saveToArtifactory = (env.getProperty('SAVE_TO_ARTIFACTORY') ?: true).toBoolean()
 distribRevision = 'proposed'
 gitGuessedVersion = false
 aptlyServerHostname = ''
@@ -472,17 +473,19 @@
             }
             // common.sendNotification(currentBuild.result,"",["slack"])
             stage('Save artifacts to Artifactory') {
-                def artifactory = new com.mirantis.mcp.MCPArtifactory()
-                def buildProps = ["context=${context['cluster_name']}"]
-                if (RequesterEmail != '' && !RequesterEmail.contains('example')) {
-                    buildProps.add("emailTo=${RequesterEmail}")
+                if (saveToArtifactory) {
+                    def artifactory = new com.mirantis.mcp.MCPArtifactory()
+                    def buildProps = ["context=${context['cluster_name']}"]
+                    if (RequesterEmail != '' && !RequesterEmail.contains('example')) {
+                        buildProps.add("emailTo=${RequesterEmail}")
+                    }
+                        def artifactoryLink = artifactory.uploadJobArtifactsToArtifactory([
+                            'artifactory'    : 'mcp-ci',
+                            'artifactoryRepo': "artifactory/drivetrain-local/${JOB_NAME}/${context['cluster_name']}-${BUILD_NUMBER}",
+                            'buildProps'     : buildProps,
+                        ])
+                        currentBuild.description += "<br/>${artifactoryLink}"
                 }
-                def artifactoryLink = artifactory.uploadJobArtifactsToArtifactory([
-                    'artifactory'    : 'mcp-ci',
-                    'artifactoryRepo': "artifactory/drivetrain-local/${JOB_NAME}/${context['cluster_name']}-${BUILD_NUMBER}",
-                    'buildProps'     : buildProps,
-                ])
-                currentBuild.description += "<br/>${artifactoryLink}"
             }
         }
     }