Merge "Fix release file detection"
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Fri, 31 Jan 2020 21:21:55 +0000 (21:21 +0000)
committerGerrit Code Review <gerrit@linuxfoundation.org>
Fri, 31 Jan 2020 21:21:55 +0000 (21:21 +0000)
1  2 
shell/release-job.sh

diff --combined shell/release-job.sh
@@@ -17,9 -17,6 +17,9 @@@ PATH=/tmp/venv/bin:$PAT
  pipup="python -m pip install -q --upgrade pip lftools jsonschema niet twine yq"
  echo "INFO: $pipup"
  $pipup
 +# show installed versions
 +python -m pip --version
 +python -m pip freeze
  
  #Functions.
  
@@@ -32,10 -29,12 +32,12 @@@ set_variables_common()
      NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/"
      # Verify if using release file or parameters
      if $USE_RELEASE_FILE ; then
-         release_files=$(git diff-tree -m --no-commit-id -r "$GIT_COMMIT" --name-only -- "releases/" ".releases/")
+         release_files=$(git diff-tree -m --no-commit-id -r "$GIT_COMMIT" "$GIT_COMMIT^1" \
+             --name-only -- "releases/" ".releases/")
          if (( $(grep -c . <<<"$release_files") > 1 )); then
            echo "INFO: RELEASE FILES ARE AS FOLLOWS: $release_files"
-           echo "ERROR: Committing multiple release files in the same commit OR rename/amend of existing files is not supported."
+           echo "ERROR: Adding multiple release files in the same commit"
+           echo "ERROR: OR rename/amend/delete of existing files is not supported."
            exit 1
          else
            release_file="$release_files"
      fi
  
      # Jenkins parameter drop-down defaults DISTRIBUTION_TYPE to None
 +    # in the contain/maven release job; get value from release yaml.
 +    # Packagecloud and PyPI jobs set the appropriate value.
      DISTRIBUTION_TYPE="${DISTRIBUTION_TYPE:-None}"
      if [[ $DISTRIBUTION_TYPE == "None" ]]; then
 -        DISTRIBUTION_TYPE=$(niet ".distribution_type" "$release_file")
 +        if ! DISTRIBUTION_TYPE=$(niet ".distribution_type" "$release_file"); then
 +            echo "ERROR: Failed to get distribution_type from $release_file"
 +            exit 1
 +        fi
      fi
  
      PATCH_DIR=$(mktemp -d)