mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-07 04:56:58 +02:00
Add retag-for-jenkins helper
When testing "scripts" changes with Jenkins and a leaf job fails, we currently would have to restart the whole build or update the git tag manually. Since dealing with the git tag is not straightforward, add a helper to update it.
This commit is contained in:
parent
1426c16a55
commit
b5bd067bdd
40
retag-for-jenkins
Executable file
40
retag-for-jenkins
Executable file
@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
echo "Usage: $0 TAG"
|
||||
echo "Rebases the free-standing git tag <TAG> on the current branch"
|
||||
echo "(make sure you don't have any uncommited local changes)"
|
||||
echo "E.g., after a Jenkins build 'alpha-9999.99.99-mytest' was started based on"
|
||||
echo "the scripts branch 'mybranch' and you have new changes on the branch,"
|
||||
echo "check out your branch and run"
|
||||
echo " $0 alpha-9999.99.99-mytest"
|
||||
echo
|
||||
echo "This is required when testing 'scripts' changes with Jenkins and a leaf job fails,"
|
||||
echo "so that instead of restarting the whole build from the 'packages' job, you can"
|
||||
echo "restart the leaf job after retagging. Note: Just starting a leaf job with your"
|
||||
echo "branch as reference is not valid because it would overwrite the nightly build"
|
||||
echo "artifacts!"
|
||||
echo
|
||||
echo "TODO: Add feature to update coreos-overlay/portage-stable submodule refs"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TAG="$1"
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
git fetch --force --tags origin
|
||||
BUILD_PATCH=$(git format-patch --output=/dev/stdout "${TAG}~1..${TAG}")
|
||||
git checkout --recurse-submodules "${TAG}"
|
||||
git reset --hard "${BRANCH}"
|
||||
echo "${BUILD_PATCH}" | git am -3 || {
|
||||
git checkout "${TAG}" -- sdk_container/.repo/manifests/version.txt
|
||||
git add sdk_container/.repo/manifests/version.txt
|
||||
git am --continue
|
||||
# This does not handle submodule conflicts: It should use the one
|
||||
# from the TAG (similar to version.txt) unless an explicit new
|
||||
# reference was specified
|
||||
} || { echo "Failed to resolve conflict, continue manually" >&2 ; exit 1 ; }
|
||||
git tag -d "${TAG}"
|
||||
git tag "${TAG}"
|
||||
git push --force origin "${TAG}"
|
Loading…
Reference in New Issue
Block a user