X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Frelease-job.sh;h=7c572cd7559794831cad35355d07dd7894413894;hb=dbd05cd4100a27a545cc2c7f0388018449d982c3;hp=68f35db3efee9839a2e5e19dde5ed086f131cc20;hpb=1396009703a2baf17938da83891714ea3db52d83;p=releng%2Fglobal-jjb.git diff --git a/shell/release-job.sh b/shell/release-job.sh index 68f35db3..7c572cd7 100644 --- a/shell/release-job.sh +++ b/shell/release-job.sh @@ -34,12 +34,13 @@ if [ "${LOGS_SERVER}" == 'None' ]; then exit 1 fi +NEXUSPROXY="${NEXUSPROXY:-None}" NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}" # Fetch the release-schema.yaml wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/release-schema.yaml -release_files=$(git diff-tree --no-commit-id -r $GERRIT_PATCHSET_REVISION --name-only -- "releases/") +release_files=$(git diff-tree --no-commit-id -r "$GERRIT_PATCHSET_REVISION" --name-only -- "releases/") echo "RELEASE FILES ARE AS FOLLOWS: $release_files" if (( $(grep -c . <<<"$release_files") > 1 )); then @@ -51,22 +52,22 @@ else fi echo "--> Verifying $release_file schema." -lftools schema verify $release_file release-schema.yaml +lftools schema verify "$release_file" release-schema.yaml VERSION="$(niet ".version" "$release_file")" -PROJECT="$(niet ".project" "$release_file")" LOG_DIR="$(niet ".log_dir" "$release_file")" - NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/" LOGS_URL="${LOGS_SERVER}/${NEXUS_PATH}${LOG_DIR}" PATCH_DIR="$(mktemp -d)" -wget --quiet -P "$PATCH_DIR" "${LOGS_URL}"staging-repo.txt.gz +LOGS_URL=${LOGS_URL%/} # strip any trailing '/' +echo "wget -P $PATCH_DIR ${LOGS_URL}/staging-repo.txt.gz" +wget -P "$PATCH_DIR" "${LOGS_URL}/"staging-repo.txt.gz nexus_release(){ for staging_url in $(zcat "$PATCH_DIR"/staging-repo.txt.gz | awk -e '{print $2}'); do # extract the domain name from URL - NEXUS_URL=$(echo $staging_url | sed -e 's|^[^/]*//||' -e 's|/.*$||') + NEXUS_URL=$(echo "$staging_url" | sed -e 's|^[^/]*//||' -e 's|/.*$||') # extract the staging repo from URL STAGING_REPO=${staging_url#*repositories/} echo "Merge will run" @@ -89,12 +90,14 @@ echo "NEXUSPROXY: $NEXUSPROXY" echo "JENKINS_HOSTNAME: $JENKINS_HOSTNAME" echo "SILO: $SILO" echo "PROJECT: $PROJECT" +echo "PROJECT-DASHED: ${PROJECT//\//-}" + echo "VERSION: $VERSION" -echo "PROJECT: $PROJECT" echo "LOG DIR: $LOG_DIR" pushd "$PATCH_DIR" - wget --quiet "${LOGS_URL}"/patches/{"${PROJECT}".bundle,taglist.log.gz} + echo "wget ${LOGS_URL}/patches/{${PROJECT//\//-}.bundle,taglist.log.gz}" + wget "${LOGS_URL}"/patches/{"${PROJECT//\//-}".bundle,taglist.log.gz} gunzip taglist.log.gz cat "$PATCH_DIR"/taglist.log popd @@ -104,27 +107,33 @@ popd allowed_version_regex="^((v?)([0-9]+)\.([0-9]+)\.([0-9]+))$" if [[ ! $VERSION =~ $allowed_version_regex ]]; then echo "The version $VERSION is not a semantic valid version" - echo "Allowed versions are "v#.#.#" or "#.#.#" aka SemVer" + echo "Allowed versions are \"v#.#.#\" or \"#.#.#\" aka SemVer" echo "See https://semver.org/ for more details on SemVer" exit 1 fi +if git tag -v "$VERSION"; then + echo "Repo already tagged $VERSION" + echo "This job has already run exit 0" + exit 0 +fi + git checkout "$(awk '{print $NF}' "$PATCH_DIR/taglist.log")" -git fetch "$PATCH_DIR/$PROJECT.bundle" +git fetch "$PATCH_DIR/${PROJECT//\//-}.bundle" git merge --ff-only FETCH_HEAD -git tag -am "$PROJECT $VERSION" "$VERSION" +git tag -am "${PROJECT//\//-} $VERSION" "$VERSION" sigul --batch -c "$SIGUL_CONFIG" sign-git-tag "$SIGUL_KEY" "$VERSION" < "$SIGUL_PASSWORD" echo "Showing latest signature for $PROJECT:" gpg --import "$SIGNING_PUBKEY" -echo "git tag -v "$VERSION"" +echo "git tag -v $VERSION" git tag -v "$VERSION" ########## Merge Part ############## if [[ "$JOB_NAME" =~ "merge" ]]; then echo "Running merge" gerrit_ssh=$(echo "$GERRIT_URL" | awk -F"/" '{print $3}') - git remote set-url origin ssh://"$RELEASE_USERNAME"@"$gerrit_ssh":29418/$PROJECT + git remote set-url origin ssh://"$RELEASE_USERNAME"@"$gerrit_ssh":29418/"$PROJECT" git config user.name "$RELEASE_USERNAME" git config user.email "$RELEASE_EMAIL" echo -e "Host $gerrit_ssh\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config @@ -136,5 +145,5 @@ fi # This function: if merge push to nexus. If verify output the proposed push command. nexus_release - -echo "########### End Script release-job.sh ###################################" +# +#echo "########### End Script release-job.sh ###################################"