X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Frelease-job.sh;h=fd43d7548fd2b0a45d47d616c3d2dca6040788ce;hb=027277490bf761405dcc4cbb02c4c92874d58766;hp=31721d11ecc253a4df7d133ce1aed491f05d8630;hpb=84da49578cee70148509f484272870ac4de7f5d5;p=releng%2Fglobal-jjb.git diff --git a/shell/release-job.sh b/shell/release-job.sh index 31721d11..fd43d754 100644 --- a/shell/release-job.sh +++ b/shell/release-job.sh @@ -51,7 +51,7 @@ tag(){ echo "git tag -v $VERSION" git tag -v "$VERSION" ########## Merge Part ############## - if [[ "$JOB_NAME" =~ "merge" ]]; then + if [[ "$JOB_NAME" =~ "merge" ]] && [[ "$DRY_RUN" = false ]]; then echo "--> INFO: Running merge" gerrit_ssh=$(echo "$GERRIT_URL" | awk -F"/" '{print $3}') git remote set-url origin ssh://"$RELEASE_USERNAME"@"$gerrit_ssh":29418/"$PROJECT" @@ -75,16 +75,60 @@ nexus_release(){ lftools nexus release -v --server https://"$NEXUS_URL" "$STAGING_REPO" echo "Merge will run" echo "lftools nexus release --server https://$NEXUS_URL $STAGING_REPO" - if [[ "$JOB_NAME" =~ "merge" ]]; then + done + + #Run the loop twice, to catch errors on either nexus repo + if [[ "$JOB_NAME" =~ "merge" ]] && [[ "$DRY_RUN" = false ]]; then + for staging_url in $(zcat "$PATCH_DIR"/staging-repo.txt.gz | awk -e '{print $2}'); do + NEXUS_URL=$(echo "$staging_url" | sed -e 's|^[^/]*//||' -e 's|/.*$||') + STAGING_REPO=${staging_url#*repositories/} echo "Promoting $STAGING_REPO on $NEXUS_URL." lftools nexus release --server https://"$NEXUS_URL" "$STAGING_REPO" - fi - done + done + fi } + container_release_file(){ echo "---> Processing container release" - # Container-release code is addressed in a new feature patchset. + local lfn_umbrella + lfn_umbrella="$(echo "$GERRIT_HOST" | awk -F"." '{print $2}')" + + + for namequoted in $(cat $release_file | yq '.containers[].name'); do + versionquoted=$(cat $release_file | yq ".containers[] |select(.name=="$namequoted") |.version") + + #Remove extra yaml quotes + name="${namequoted#\"}" + name="${name%\"}" + version="${versionquoted#\"}" + version="${version%\"}" + + echo "$name" + echo "$version" + echo "---> INFO: Merge will release $name $version as $VERSION" + #Pull from public, to see if we have already tagged this. + if docker pull "$DOCKER_REGISTRY":10002/"$lfn_umbrella"/"$name":"$VERSION"; then + echo "---> OK: $VERSION is already released for image $name, Continuing..." + else + echo "---> OK: $VERSION not found in releases, release will be prepared. Continuing..." + docker pull "$DOCKER_REGISTRY":10001/"$lfn_umbrella"/"$name":"$version" + container_image_id="$(docker images | grep $name | grep $version | awk '{print $3}')" + echo "---> INFO: Merge will run the following commands:" + echo "docker tag $container_image_id $DOCKER_REGISTRY:10002/$lfn_umbrella/$name:$VERSION" + echo "docker push $DOCKER_REGISTRY:10002/$lfn_umbrella/$name:$VERSION" + if [[ "$JOB_NAME" =~ "merge" ]]; then + docker tag "$container_image_id" "$DOCKER_REGISTRY":10002/"$lfn_umbrella"/"$name":"$VERSION" + docker push "$DOCKER_REGISTRY":10002/"$lfn_umbrella"/"$name":"$VERSION" + fi + echo "#########################" + fi + done + + ref="$(niet ".ref" "$release_file")" + echo "---> INFO: Merge will tag ref: $ref" + git checkout "$ref" + tag } maven_release_file(){ @@ -113,8 +157,7 @@ if [ "${LOGS_SERVER}" == 'None' ]; then exit 1 fi -RELEASE_FILE="${RELEASE_FILE:-True}" -if [[ "$RELEASE_FILE" == "True" ]]; then +if $USE_RELEASE_FILE ; then release_files=$(git diff-tree --no-commit-id -r "$GERRIT_PATCHSET_REVISION" --name-only -- "releases/" ".releases/") if (( $(grep -c . <<<"$release_files") > 1 )); then @@ -127,7 +170,7 @@ if [[ "$RELEASE_FILE" == "True" ]]; then fi else - echo "This is job is built with parameters, no release file needed" + echo "This job is built with parameters, no release file needed. Continuing..." release_file="None" fi @@ -173,12 +216,14 @@ echo "DISTRIBUTION_TYPE: $DISTRIBUTION_TYPE" if [[ "$DISTRIBUTION_TYPE" == "maven" ]]; then wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/release-schema.yaml RELEASE_SCHEMA="release-schema.yaml" - if [[ "$RELEASE_FILE" == "True" ]]; then + if $USE_RELEASE_FILE ; then verify_schema fi maven_release_file elif [[ "$DISTRIBUTION_TYPE" == "container" ]]; then - # Container-release code is addressed in a new feature patchset. + wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/release-container-schema.yaml + RELEASE_SCHEMA="release-container-schema.yaml" + verify_schema container_release_file else echo "---> ERROR: distribution_type: $DISTRIBUTION_TYPE not supported" @@ -188,4 +233,3 @@ fi ########################################## echo "########### End Script release-job.sh ###################################" -