The release merge job is a one way operation.
Given this, Release jobs should only exist in the format
{project-name}-release-verify
and
{project-name}-release-merge
They should trigger from a change to any branch/**
As a developer working on {example-branch} will not want to
check out master to push a new release file.
Edge Cases:
Inevitably a release file will be pulled in from master to {example-branch}
or a remerge will be requested
This will again trigger the release jobs.
since in this case the repo is already tagged, the job should not report
a failure.
This is solved by having the verfiy and merge exit 0 when the repo is already tagged
if git tag -v "$VERSION"; then
echo "Repo already tagged $VERSION"
echo "This job has already run exit 0"
exit 0
if
Example Workflow - Milestone 0 is released from master:
releases/1.4.0.yaml (on branch master)
tag: 1.4.0
log_dir: 'optf-osdf-maven-stage-master/97/'
Repo is tagged and artifact is pushed!
Milestone 3 is released from dublin:
releases/1.4.3.yaml (on branch dublin)
tag: 1.4.3
log_dir: 'optf-osdf-maven-stage-dublin/20/'
Repo is tagged and artifact is pushed!
Note:
the ref is determined by the log file.
So We could check if this ref can be found on the {branch}
to reduce human errors.
example:
odlparent-maven-stage-4.0.x/152/patches/taglist.log.gz
has:
odlparent
c8964051cf81e2bd5d831fe6e5d568c5eedeeb8e
Psudo code:
STREAM=${STREAM:-'nostream'}
echo "--> Checking if $ref is on stable/$STREAM"
if ! (git branch -a --contains $ref | grep "stable/$STREAM"); then
echo "--> ERROR: $ref for $repo is not on stable/$STREAM!"
fi
Also in this patch:
To reduce possible errors:
Don't get project name from the release file:
PROJECT="$(niet ".project" "$release_file")"
we can just use ${PROJECT//\//-} when we need
the /'s changed to -'s
It will allways be correct when passed to jenkins
from gerrit
Also remove quiet from wget,
if there is a failure I want to see it on the console.
Signed-off-by: Aric Gardner <agardner@linuxfoundation.org>
Change-Id: I1e95e864bc2b49a62b3f7016cb2f1292a6687d9a
parameters:
- lf-infra-parameters:
project: "{project}"
- branch: "master"
- stream: "{stream}"
+ branch: "$GERRIT_BRANCH"
+ stream: "$GERRIT_BRANCH"
wrappers:
- lf-infra-wrappers:
# Default parameters #
######################
- branch: master
- stream: master
build-days-to-keep: 7
build-timeout: 15
disable-job: false
- lf-release
- job-template:
- name: "{project-name}-release-verify-{stream}"
+ name: "{project-name}-release-verify"
id: gerrit-release-verify
<<: *lf_release_common
# yamllint disable-line rule:key-duplicates
- lf-infra-gerrit-scm:
git-url: "{git-url}"
refspec: "$GERRIT_REFSPEC"
- branch: "master"
+ branch: "$GERRIT_BRANCH"
submodule-disable: true
submodule-recursive: false
submodule-timeout: 10
project-pattern: "{project}"
branches:
- branch-compare-type: "ANT"
- branch-pattern: "**/{branch}"
+ branch-pattern: "**"
file-paths: "{obj:gerrit_trigger_file_paths}"
skip-vote:
successful: "{gerrit-skip-vote}"
# Default parameters #
######################
- branch: master
- stream: master
build-days-to-keep: 7
build-timeout: 15
disable-job: false
- lf-release
- job-template:
- name: "{project-name}-release-merge-{stream}"
+ name: "{project-name}-release-merge"
id: gerrit-release-merge
<<: *lf_release_common
# yamllint disable-line rule:key-duplicates
project-pattern: "{project}"
branches:
- branch-compare-type: "ANT"
- branch-pattern: "**/{branch}"
+ branch-pattern: "**"
file-paths: "{obj:gerrit_trigger_file_paths}"
--- /dev/null
+---
+fixes:
+ - |
+ 1.
+ The release merge job is a one way operation.
+ Given this, Release jobs should only exist in the format
+ {project-name}-release-verify and
+ {project-name}-release-merge
+ As these jobs trigger from a change to any branch/**
+ These jobs Must Exit 0 if release job has already tagged a repo.
+ Inevitably a release file will be pulled in from master to branch
+ or a remerge will be requested This will again trigger the release jobs.
+ since in this case the repo is already tagged, the job should not report
+ a failure. This is solved by having the verfiy and merge exit 0 when the
+ repo is already tagged
+ 2.
+ Rather than use project as defined in the release file use
+ ${PROJECT//\//-}
+ This changes PROJECT="optf/osdf/foo/bar" to
+ optf-osdf-foo-bar so that we can fetch the log files.
+ by changing /'s in the project names to -'s
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)"
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(){
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
exit 1
fi
+if git tag -v "$VERSION"; then
+ echo "Repo already tagged $VERSION"
+ echo "This job has already run exit 0"
+ exit 0
+if
+
git checkout "$(awk '{print $NF}' "$PATCH_DIR/taglist.log")"
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:"
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/$GERRIT_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