Refactor docker push script to accept image name

Change-Id: If465a45ac93fca37adf07ca94e5d7ac925a808db
Issue-id: CIMAN-23
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
diff --git a/jjb/global-macros.yaml b/jjb/global-macros.yaml
index 454d056..826b604 100644
--- a/jjb/global-macros.yaml
+++ b/jjb/global-macros.yaml
@@ -109,6 +109,16 @@
           # yamllint enable
           description: 'Maven selector to be used by shell scripts'
 
+- parameter:
+    name: docker-image-name
+    parameters:
+      - string:
+          name: DOCKER_IMAGE_NAME
+          # yamllint disable rule:line-length
+          default: '{docker-image-name}'
+          # yamllint enable
+          description: 'Docker image name, e.g. onap/appc'
+
 # PROPERTIES
 - property:
     name: infra-properties
diff --git a/jjb/global-templates-java.yaml b/jjb/global-templates-java.yaml
index 21a227b..23d74c6 100644
--- a/jjb/global-templates-java.yaml
+++ b/jjb/global-templates-java.yaml
@@ -1342,6 +1342,7 @@
     name: '{project-name}-{stream}-aai-docker-java-daily'
     project-type: freestyle
     node: 'ubuntu1604-docker-8c-8g'
+    docker-image-name: ''
 
     properties:
       - infra-properties:
@@ -1355,6 +1356,8 @@
           artifacts: '{archive-artifacts}'
       - maven-exec:
           maven-version: '{maven-version}'
+      - docker-image-name:
+          docker-image-name: '{docker-image-name}'
 
     scm:
       - gerrit-trigger-scm:
diff --git a/jjb/include-docker-push.sh b/jjb/include-docker-push.sh
index 57a0264..1a89fe7 100644
--- a/jjb/include-docker-push.sh
+++ b/jjb/include-docker-push.sh
@@ -20,40 +20,31 @@
 SNAPSHOT_TAG=${VERSION}-SNAPSHOT-${DATETIME_STAMP};
 STAGING_TAG=${VERSION}-STAGING-${DATETIME_STAMP};
 
-if [[ $PROJECT =~ $SEARCH ]] ; then
 
+# Set REPO_PATH variable
+
+if [ ! -z "$DOCKER_IMAGE_NAME" ]; then
+    REPO_PATH=$DOCKER_REPOSITORY/${$DOCKER_IMAGE_NAME};
+elif [[ $PROJECT =~ $SEARCH ]] ; then
     REPO_PATH=$DOCKER_REPOSITORY/openecomp/ajsc-aai;
-
-    docker tag $REPO_PATH:latest $REPO_PATH:$STAGING_TAG;
-    docker tag $REPO_PATH:latest $REPO_PATH:$SNAPSHOT_TAG;
-
-    if [[ "$VERSION" =~ $RELEASE_VERSION_REGEX ]]; then
-        STRIPPED_RELEASE=$(echo $VERSION | cut -d"." -f1,2);
-        docker tag $REPO_PATH:latest $REPO_PATH:${STRIPPED_RELEASE}-STAGING-latest;
-        docker push $REPO_PATH:${STRIPPED_RELEASE}-STAGING-latest;
-    else
-        docker push $REPO_PATH:latest;
-    fi
-
-    docker push $REPO_PATH:$STAGING_TAG;
-    docker push $REPO_PATH:$SNAPSHOT_TAG;
 else
     # Cut the prefix aai/ in example aai/model-loader
     DOCKER_REPO_NAME=$(echo ${PROJECT} | cut -d"/" -f2-);
 
     REPO_PATH=$DOCKER_REPOSITORY/openecomp/${DOCKER_REPO_NAME};
-
-    docker tag $REPO_PATH:latest $REPO_PATH:$STAGING_TAG;
-    docker tag $REPO_PATH:latest $REPO_PATH:$SNAPSHOT_TAG;
-
-    if [[ "$VERSION" =~ $RELEASE_VERSION_REGEX ]]; then
-        STRIPPED_RELEASE=$(echo $VERSION | cut -d"." -f1,2);
-        docker tag $REPO_PATH:latest $REPO_PATH:${STRIPPED_RELEASE}-STAGING-latest;
-        docker push $REPO_PATH:${STRIPPED_RELEASE}-STAGING-latest;
-    else
-        docker push $REPO_PATH:latest;
-    fi
-
-    docker push $REPO_PATH:$SNAPSHOT_TAG;
-    docker push $REPO_PATH:$STAGING_TAG;
 fi
+
+
+docker tag $REPO_PATH:latest $REPO_PATH:$STAGING_TAG;
+docker tag $REPO_PATH:latest $REPO_PATH:$SNAPSHOT_TAG;
+
+if [[ "$VERSION" =~ $RELEASE_VERSION_REGEX ]]; then
+    STRIPPED_RELEASE=$(echo $VERSION | cut -d"." -f1,2);
+    docker tag $REPO_PATH:latest $REPO_PATH:${STRIPPED_RELEASE}-STAGING-latest;
+    docker push $REPO_PATH:${STRIPPED_RELEASE}-STAGING-latest;
+else
+    docker push $REPO_PATH:latest;
+fi
+
+docker push $REPO_PATH:$SNAPSHOT_TAG;
+docker push $REPO_PATH:$STAGING_TAG;