From: Jessica Wagantall Date: Wed, 20 Jan 2021 21:10:01 +0000 (-0800) Subject: Add support for artifact releases X-Git-Tag: v0.62.0~5 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F47%2F66647%2F6;p=releng%2Fglobal-jjb.git Add support for artifact releases Currently Dent is the only customer for artifact releases where they need a particular binary to be pulled from Snapshots and pushed manually into Releases. These are artifacts built using make. Issue: RELENG-3376 Signed-off-by: Jessica Wagantall Change-Id: I5a8ec8e2906757b1700505ad10dd2ba8ac844f9a --- diff --git a/releasenotes/notes/artifacts-self-releases-support-0448d5269ac8f30f.yaml b/releasenotes/notes/artifacts-self-releases-support-0448d5269ac8f30f.yaml new file mode 100644 index 00000000..3f26ae28 --- /dev/null +++ b/releasenotes/notes/artifacts-self-releases-support-0448d5269ac8f30f.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Add artifact distribution type for self releases. + This support allows customers to specify a particular name + and path of an artifact in Nexus which will be downloaded locally, + re-tagged and posted into the releases repository of the matching repo. diff --git a/shell/release-job.sh b/shell/release-job.sh index 9ff67994..66bed669 100644 --- a/shell/release-job.sh +++ b/shell/release-job.sh @@ -83,7 +83,7 @@ set_variables_common(){ # Displaying Release Information (Common variables) printf "\t%-30s\n" RELEASE_ENVIRONMENT_INFO: printf "\t%-30s %s\n" RELEASE_FILE: "$release_file" - printf "\t%-30s %s\n" LOGS_SERVER: "$LOGS_SERVER" + printf "\t%-30s %s\n" LOGS_SERVER: "${LOGS_SERVER:-None}" printf "\t%-30s %s\n" CDN_URL: "${CDN_URL:-None}" printf "\t%-30s %s\n" NEXUS_PATH: "$NEXUS_PATH" printf "\t%-30s %s\n" JENKINS_HOSTNAME: "$JENKINS_HOSTNAME" @@ -217,6 +217,28 @@ set_variables_packagecloud(){ printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG" } +set_variables_artifact(){ + echo "INFO: Setting artifact variables" + if [[ -z ${VERSION:-} ]]; then + VERSION=$(yq -r ".version" "$release_file") + fi + if [[ -z ${GIT_TAG:-} ]]; then + if grep -q "git_tag" $release_file ; then + GIT_TAG=$(yq -r ".git_tag" "$release_file") + else + GIT_TAG="$VERSION" + fi + fi + if [[ -z ${REF:-} ]]; then + REF=$(yq -r ".ref" "$release_file") + fi + + printf "\t%-30s\n" RELEASE_ARTIFACT_INFO: + printf "\t%-30s %s\n" GERRIT_REF_TO_TAG: "$REF" + printf "\t%-30s %s\n" VERSION: "$VERSION" + printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG" +} + verify_schema(){ echo "INFO: Verifying $release_file against schema $release_schema" lftools schema verify "$release_file" "$release_schema" @@ -494,18 +516,64 @@ packagecloud_promote(){ tag-git-repo } +artifact_release_file(){ + echo "INFO: Processing artifact release" + mkdir artifacts + ORG=$(echo "$NEXUS_URL" | awk -F'.' '{print $2}') + + for namequoted in $(yq '.artifacts[].name' $release_file); do + pathquoted=$(yq ".artifacts[] |select(.name==$namequoted) |.path" $release_file) + + #Remove extra yaml quotes + name="${namequoted#\"}" + name="${name%\"}" + path="${pathquoted#\"}" + path="${path%\"}" + + echo "$name" + echo "$path" + echo "INFO: Merge will post artifact: $name" + # Attempt to pull from releases to see if the artifact has been released. + if "${NEXUS_URL}"/content/repositories/releases/org/"${ORG}"/"${VERSION}"/"$name"; then + echo "INFO: $name is already released as version:$VERSION, Continuing..." + else + echo "INFO: $name not found in releases, release will be prepared. Continuing..." + wget "${path}"/"${name}" -o artifacts/"${name}" + if [[ "$JOB_NAME" =~ "merge" ]] && [[ "$DRY_RUN" = false ]]; then + #lftools sign sigul artifacts + curl -v -u : --upload-file "${NEXUS_URL}"/content/repositories/releases/org/"${ORG}"/"${VERSION}"/"${name}" \; + fi + echo "#########################" + fi + done +} + ############################## End Function Declarations ################################ # Set common environment variables set_variables_common # Determine the type of release: +# - artifact, release-artifact-schema.yaml # - container, release-container-schema.yaml # - maven, release-schema.yaml # - pypi, release-pypi-schema.yaml +# - packagecloud, release-packagecloud-schema.yaml case $DISTRIBUTION_TYPE in + artifact) + if $USE_RELEASE_FILE ; then + release_schema="release-artifact-schema.yaml" + echo "INFO: Fetching schema $release_schema" + wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/${release_schema} + verify_schema + fi + set_variables_artifact + verify_version + artifact_release_file + ;; + maven) if $USE_RELEASE_FILE ; then release_schema="release-schema.yaml"