Add ability to run merge-topic.py as part of clone-source.sh
Change-Id: I35aa8a5227648603b48c36d216d1995c47d557aa Signed-off-by: Scott Little <scott.little@windriver.com>
This commit is contained in:
@@ -243,7 +243,14 @@ or with paths relative to repo root:
|
||||
</code></pre>
|
||||
'''
|
||||
)
|
||||
|
||||
text (
|
||||
name: 'PATCH_TOPIC',
|
||||
defaultValue: '-',
|
||||
description: '''\
|
||||
<pre><code>List of Gerrit topics to cherry-pick, one per line.
|
||||
</code></pre>
|
||||
'''
|
||||
)
|
||||
}
|
||||
stages {
|
||||
stage('INIT') {
|
||||
|
||||
@@ -47,6 +47,10 @@ pipeline {
|
||||
name: 'PATCH_LIST',
|
||||
defaultValue: '-'
|
||||
)
|
||||
text (
|
||||
name: 'PATCH_TOPIC',
|
||||
defaultValue: '-'
|
||||
)
|
||||
}
|
||||
stages {
|
||||
stage ("clone-source") {
|
||||
|
||||
@@ -237,6 +237,14 @@ or with paths relative to repo root:
|
||||
cgcs-root/stx/config https://review.opendev.org/starlingx/config refs/changes/71/859571/4
|
||||
cgcs-root/stx/stx-puppet https://review.opendev.org/starlingx/stx-puppet refs/changes/75/859575/1
|
||||
stx-tools https://review.opendev.org/starlingx/tools refs/changes/76/859576/2
|
||||
</code></pre>
|
||||
'''
|
||||
)
|
||||
text (
|
||||
name: 'PATCH_TOPIC',
|
||||
defaultValue: '-',
|
||||
description: '''\
|
||||
<pre><code>List of Gerrit topics to cherry-pick, one per line.
|
||||
</code></pre>
|
||||
'''
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Copyright (c) 2022 Wind River Systems, Inc.
|
||||
# Copyright (c) 2022,2025 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@@ -14,6 +14,7 @@ require_job_env BUILD_HOME
|
||||
require_job_env DRY_RUN
|
||||
require_job_env REFRESH_SOURCE
|
||||
declare_job_env PATCH_LIST
|
||||
declare_job_env PATCH_TOPIC
|
||||
|
||||
# Some jenkins versions have a bug that causes misbehavior
|
||||
# when a multi-line parameter is empty. Treat "-" as empty
|
||||
@@ -22,6 +23,10 @@ PATCH_LIST="$(echo "$PATCH_LIST" | grep -v -E '^\s*(#.*)?$' | sed -r -e 's/^\s+/
|
||||
if [[ "$PATCH_LIST" == "-" ]] ; then
|
||||
PATCH_LIST=
|
||||
fi
|
||||
PATCH_TOPIC="$(echo "$PATCH_TOPIC" | grep -v -E '^\s*(#.*)?$' | sed -r -e 's/^\s+//g' -e 's/\s+$//g')"
|
||||
if [[ "$PATCH_TOPIC" == "-" ]] ; then
|
||||
PATCH_TOPIC=
|
||||
fi
|
||||
|
||||
load_build_env
|
||||
|
||||
@@ -233,7 +238,7 @@ if [[ -n "$PATCH_LIST" ]] ; then
|
||||
[[ -n "$project" ]] || continue
|
||||
# abort in-progress "rebase" etc
|
||||
info "" "--- $path: resetting git checkout" ""
|
||||
shell $DRY_RUN_ARH "\
|
||||
shell $DRY_RUN_ARG "\
|
||||
set -e
|
||||
cd \"$path\"
|
||||
git rebase --abort >/dev/null 2>&1 || :
|
||||
@@ -256,3 +261,35 @@ git checkout .
|
||||
shell $DRY_RUN_ARG "cd \"$path\" && git fetch \"$url\" \"$ref\" && git cherry-pick FETCH_HEAD"
|
||||
done <<<"$(echo "$PATCH_SPECS")"
|
||||
fi
|
||||
|
||||
# Apply patches in "$PATCH_TOPIC" parameter given one per line:
|
||||
if [[ -n "$PATCH_TOPIC" ]] ; then
|
||||
notice "Applying patches from topic(s)"
|
||||
|
||||
MERGE_TOPIC_BIN="${REPO_ROOT}/cgcs-root/build-tools/merge-topic/merge-topic.py"
|
||||
MERGE_TOPIC_ARGS="repo --repo-root-dir ${REPO_ROOT} --download-strategy 'Cherry Pick' --merge-fixer 'pick_both_merge_fixer.py'"
|
||||
fail=0
|
||||
while read line ; do
|
||||
# skip empty lines
|
||||
if [[ -z "$line" || "${line[0]}" == "#" ]] ; then
|
||||
continue
|
||||
fi
|
||||
# split by whitespace
|
||||
declare -a parts=($line)
|
||||
if [[ "${#parts[@]}" -eq 1 ]] ; then
|
||||
topic="${parts[0]}"
|
||||
else
|
||||
error "Invalid topic \"$line\"" \
|
||||
"Expecting TOPIC"
|
||||
fail=1
|
||||
continue
|
||||
fi
|
||||
|
||||
MERGE_TOPIC_ARGS="${MERGE_TOPIC_ARGS} --topic $topic"
|
||||
|
||||
done <<<"$PATCH_TOPIC"$'\n'
|
||||
[[ $fail -eq 0 ]] || exit 1
|
||||
|
||||
shell $DRY_RUN_ARG "${MERGE_TOPIC_BIN} ${MERGE_TOPIC_ARGS}" || exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user