set -ex
if [ ! -z ${GERRIT_REVIEW} ] ; then
- refspec=$(curl "https://review.fuel-infra.org/changes/?q=${GERRIT_REVIEW}&o=CURRENT_REVISION" | grep '"ref":' | awk -F ": " '{print $2}' | tr -d '"')
+ refspec=$(curl "https://review.fuel-infra.org/changes/?q=${GERRIT_REVIEW}&o=CURRENT_REVISION" | sed 's|.*\(refs/changes/[0-9]\+/[0-9]\+/[0-9]\+\).*|\1|p' | tail -n1)
git fetch https://review.fuel-infra.org/tools/sustaining "${refspec}" && git cherry-pick -n FETCH_HEAD
fi
pushd ${REPO_DIR:-.}
if [[ ! -z ${GERRIT_REVIEW} ]] ; then
-refspec=$(curl "https://review.fuel-infra.org/changes/?q=${GERRIT_REVIEW}&o=CURRENT_REVISION" | grep '"ref":' | awk -F ": " '{print $2}' | tr -d '"')
+refspec=$(curl "https://review.fuel-infra.org/changes/?q=${GERRIT_REVIEW}&o=CURRENT_REVISION" | sed 's|.*\(refs/changes/[0-9]\+/[0-9]\+/[0-9]\+\).*|\1|p' | tail -n1)
git fetch https://review.fuel-infra.org/tools/sustaining "${refspec}" && git cherry-pick -n FETCH_HEAD
fi
pushd maintenance-ci
if [[ ! -z ${GERRIT_REVIEW} ]] ; then
-refspec=$(curl "https://review.fuel-infra.org/changes/?q=${GERRIT_REVIEW}&o=CURRENT_REVISION" | grep '"ref":' | awk -F ": " '{print $2}' | tr -d '"')
+refspec=$(curl "https://review.fuel-infra.org/changes/?q=${GERRIT_REVIEW}&o=CURRENT_REVISION" | sed 's|.*\(refs/changes/[0-9]\+/[0-9]\+/[0-9]\+\).*|\1|p' | tail -n1)
git fetch https://review.fuel-infra.org/tools/sustaining "${refspec}" && git cherry-pick -n FETCH_HEAD
fi
popd
pushd maintenance-ci
if [ ! -z ${GERRIT_REVIEW} ] ; then
-refspec=$(curl "https://review.fuel-infra.org/changes/?q=${GERRIT_REVIEW}&o=CURRENT_REVISION" | grep '"ref":' | awk -F ": " '{print $2}' | tr -d '"')
+refspec=$(curl "https://review.fuel-infra.org/changes/?q=${GERRIT_REVIEW}&o=CURRENT_REVISION" | sed 's|.*\(refs/changes/[0-9]\+/[0-9]\+/[0-9]\+\).*|\1|p' | tail -n1)
git fetch https://review.fuel-infra.org/tools/sustaining "${refspec}" && git cherry-pick -n FETCH_HEAD
fi
set -x
if [[ ! -z ${FUEL_QA_GERRIT_REVIEW} ]] ; then
-refspec=$(curl "https://review.fuel-infra.org/changes/?q=${FUEL_QA_GERRIT_REVIEW}&o=CURRENT_REVISION" | grep '"ref":' | awk -F ": " '{print $2}' | tr -d '"')
+refspec=$(curl "https://review.fuel-infra.org/changes/?q=${FUEL_QA_GERRIT_REVIEW}&o=CURRENT_REVISION" | sed 's|.*\(refs/changes/[0-9]\+/[0-9]\+/[0-9]\+\).*|\1|p' | tail -n1)
git fetch https://review.fuel-infra.org/openstack/fuel-qa "${refspec}" && git cherry-pick -n FETCH_HEAD
fi
if [[ ! -z ${FUEL_QA_GERRIT_REVIEW} ]] ; then
-refspec=$(curl "https://review.fuel-infra.org/changes/?q=${FUEL_QA_GERRIT_REVIEW}&o=CURRENT_REVISION" | grep '"ref":' | awk -F ": " '{print $2}' | tr -d '"')
+refspec=$(curl "https://review.fuel-infra.org/changes/?q=${FUEL_QA_GERRIT_REVIEW}&o=CURRENT_REVISION" | sed 's|.*\(refs/changes/[0-9]\+/[0-9]\+/[0-9]\+\).*|\1|p' | tail -n1)
git fetch https://review.fuel-infra.org/openstack/fuel-qa "${refspec}" && git cherry-pick -n FETCH_HEAD
fi