Merge "Update generate-cookiecutter-products"
diff --git a/build-debian-packages-pipeline.groovy b/build-debian-packages-pipeline.groovy
index 5d16339..864f0bc 100644
--- a/build-debian-packages-pipeline.groovy
+++ b/build-debian-packages-pipeline.groovy
@@ -64,12 +64,16 @@
           checkout changelog: true, poll: false,
             scm: [$class: 'GitSCM', branches: pollBranches, doGenerateSubmoduleConfigurations: false,
             extensions: extensions,  submoduleCfg: [], userRemoteConfigs: userRemoteConfigs]
+
+          /* There are 2 schemas of build spec keeping:
+                 1. Separate directory with specs.
+                 2. Separate branch with build specs. I.e. debian/xenial
+             Logic below makes package build compatible with both schemas.
+          */
+          if (fileExists('debian/changelog')) {
+              debian_branch = null
+          }
           if (debian_branch){
-            /* There are 2 schemas of build spec keeping:
-                   1. Separate branch with build specs. I.e. debian/xenial
-                   2. Separate directory with specs.
-               Logic below makes package build compatible with both schemas.
-            */
             def retStatus = sh(script: 'git checkout ' + DEBIAN_BRANCH, returnStatus: true)
             if (retStatus != 0) {
               common.warningMsg("Cannot checkout ${DEBIAN_BRANCH} branch. Going to build package by ${SOURCE_BRANCH} branch.")
diff --git a/docker-mirror-images.groovy b/docker-mirror-images.groovy
index ebbfc86..07a80e7 100644
--- a/docker-mirror-images.groovy
+++ b/docker-mirror-images.groovy
@@ -42,7 +42,7 @@
                     imagePath = imageArray[0]
                     if (imagePath.contains('SUBS_SOURCE_IMAGE_TAG')) {
                         common.warningMsg("Replacing SUBS_SOURCE_IMAGE_TAG => ${SOURCE_IMAGE_TAG}")
-                        imagePath.replace('SUBS_SOURCE_IMAGE_TAG', SOURCE_IMAGE_TAG)
+                        imagePath = imagePath.replace('SUBS_SOURCE_IMAGE_TAG', SOURCE_IMAGE_TAG)
                     }
                     targetRegistry = imageArray[1]
                     imageName = getImageName(imagePath)
diff --git a/tag-git-repos.groovy b/tag-git-repos.groovy
index dabbb7f..312ec9e 100644
--- a/tag-git-repos.groovy
+++ b/tag-git-repos.groovy
@@ -44,7 +44,7 @@
         repoCommit = repoArray[2]
         if (repoCommit.contains('SUBS_SOURCE_REF')) {
           common.warningMsg("Replacing SUBS_SOURCE_REF => ${SOURCE_TAG}")
-          repoCommit.replace('SUBS_SOURCE_REF', SOURCE_TAG
+          repoCommit = repoCommit.replace('SUBS_SOURCE_REF', SOURCE_TAG
             )
         }
         gitRepoAddTag(repoUrl, repoName, TAG, GIT_CREDENTIALS, repoCommit)