Add support for offline package and test for onap release job
[infra/cicd.git] / jjb / cloud-infra / scripts / generate-change-metadata.sh
index 73f889748eb8e892450a88d52c1eb01f911ddd19..878735d2c5b667a1a8f60944c1c54841c74ee92e 100755 (executable)
@@ -43,7 +43,7 @@ function determine_dependency() {
   echo "Info  : Processing change $DEPENDENT_CHANGE_ID"
   declare -a DEPENDENT_CHANGE_METADATA
   readarray -t DEPENDENT_CHANGE_METADATA < <(curl -s "https://gerrit.nordix.org/changes/?q=$DEPENDENT_CHANGE_ID&o=CURRENT_REVISION" 2>&1 \
-      | grep "project\|status\|current_revision\|ref.*," | sed -e 's/\s//g' -e 's/,//g' -e 's/"//g'| cut -d: -f2)
+      | grep "project\|status\|current_revision\|ref\".*," | sed -e 's/\s//g' -e 's/,//g' -e 's/"//g'| cut -d: -f2)
 
   # NOTE (fdegir): check if the dependeny change exists
   # and ignore if it doesn't
@@ -103,6 +103,17 @@ echo "Info  : Generating change metadata"
 # this scripts is used by all engine repos so we need to determine what this change is for
 export ENGINE_COMPONENT="${GERRIT_PROJECT//*\//}"
 
+# Check if we need to override the deploy scenario.
+if ! echo "$GERRIT_CHANGE_COMMIT_MESSAGE" | grep -qs "^Deploy-Scenario:"; then
+  echo "Info  : No DEPLOY_SCENARIO override found."
+else
+  echo "Info  : DEPLOY_SCENARIO override found!"
+  echo "Info  : Before override: DEPLOY_SCENARIO=${DEPLOY_SCENARIO}"
+  DEPLOY_SCENARIO=$(echo "$GERRIT_CHANGE_COMMIT_MESSAGE" | grep '^Deploy-Scenario:' | cut -d ":" -f2 | sed 's/\s*//g')
+  export DEPLOY_SCENARIO
+  echo "Info  : After override: DEPLOY_SCENARIO=${DEPLOY_SCENARIO}"
+fi
+
 echo "Info  : Setting STACK_TYPE and STACK_VERSION"
 if [[ "$GERRIT_PROJECT" =~ /stack/ ]]; then
   # set vars
@@ -141,8 +152,10 @@ elif [[ "$GERRIT_PROJECT" =~ /installer/ ]]; then
   echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION" >> "$CHANGE_METADATA_FILE"
   echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC" >> "$CHANGE_METADATA_FILE"
 else
+  # NOTE (fdegir): if the change comes into provisioner repos, we need to set the stack type
+  # properly for the jobs verifying those changes
   # set vars
-  export STACK_TYPE=kubernetes
+  export STACK_TYPE="${STACK_TYPE:-kubernetes}"
   export STACK_VERSION=$GERRIT_BRANCH
 
   # record vars to properties file