X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Frelease-job.sh;h=6a5aeed4551071f365d29838d20700653e697904;hb=refs%2Fchanges%2F04%2F63004%2F2;hp=220f016c0e5a8cc9d72d388d845d651ad04718df;hpb=be791d789e3e0049575d5e6b4ad1e414b825e1e6;p=releng%2Fglobal-jjb.git diff --git a/shell/release-job.sh b/shell/release-job.sh index 220f016c..6a5aeed4 100644 --- a/shell/release-job.sh +++ b/shell/release-job.sh @@ -17,6 +17,9 @@ PATH=/tmp/venv/bin:$PATH 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. @@ -29,10 +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" @@ -44,9 +49,14 @@ set_variables_common(){ 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) @@ -240,7 +250,7 @@ verify_packagecloud_match_release(){ echo "INFO: Fetching console log from $logs_url" wget -q -P /tmp "${logs_url}/"console.log.gz echo "INFO: Searching for uploaded step, package name $PACKAGE_NAME and version $VERSION in job log" - if zgrep "Successfully uploaded" /tmp/console.log.gz | grep "$PACKAGE_NAME" | grep "$VERSION"; then + if zgrep -E "Pushing.*$PACKAGE_NAME.*$VERSION.*success\!" /tmp/console.log.gz; then echo "INFO: found expected strings in job log" else echo "ERROR: failed to find expected strings in job log" @@ -313,8 +323,8 @@ container_release_file(){ local lfn_umbrella lfn_umbrella="$(echo "$GERRIT_URL" | awk -F"." '{print $2}')" - for namequoted in $(cat $release_file | yq '.containers[].name'); do - versionquoted=$(cat $release_file | yq ".containers[] |select(.name==$namequoted) |.version") + for namequoted in $(yq '.containers[].name' $release_file); do + versionquoted=$(yq ".containers[] |select(.name==$namequoted) |.version" $release_file) #Remove extra yaml quotes name="${namequoted#\"}" @@ -384,6 +394,7 @@ pypi_release_file(){ echo "WARN: failed to download source distribution" fi echo "INFO: Checking files in $tgtdir" + # shellcheck disable=SC2012 filecount=$(ls $tgtdir | wc -l) if [[ $filecount = 0 ]] ; then echo "ERROR: no files downloaded"