rhtyd closed pull request #2627: Catch error in packagin script and fail the
build
URL: https://github.com/apache/cloudstack/pull/2627
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/packaging/package.sh b/packaging/package.sh
index c4f2c489e2b..7432da72452 100755
--- a/packaging/package.sh
+++ b/packaging/package.sh
@@ -162,11 +162,16 @@ function packaging() {
cp "$PWD/$DISTRO/cloud.spec" "$RPMDIR/SPECS"
(cd "$RPMDIR"; rpmbuild --define "_topdir ${RPMDIR}" "${DEFVER}"
"${DEFFULLVER}" "${DEFREL}" ${DEFPRE+"$DEFPRE"} ${DEFOSSNOSS+"$DEFOSSNOSS"}
${DEFSIM+"$DEFSIM"} -bb SPECS/cloud.spec)
- (cd $PWD/../; git reset --hard)
if [ $? -ne 0 ]; then
+ if [ "$USE_TIMESTAMP" == "true" ]; then
+ (cd $PWD/../; git reset --hard)
+ fi
echo "RPM Build Failed "
exit 3
else
+ if [ "$USE_TIMESTAMP" == "true" ]; then
+ (cd $PWD/../; git reset --hard)
+ fi
echo "RPM Build Done"
fi
exit
@@ -259,5 +264,16 @@ if [ -n "$unrecognized_flags" ]; then
echo ""
fi
+# Fail early if working directory is NOT clean and --use-timestamp was provided
+if [ "$USE_TIMESTAMP" == "true" ]; then
+ if [ -n "$(cd $PWD/../; git status -s)" ]; then
+ echo "Erro: You have uncommitted changes and asked for --use-timestamp
to be used."
+ echo " --use-timestamp flag is going to temporarily change POM
versions and"
+ echo " revert them at the end of build, and there's no way we
can do partial"
+ echo " revert. Please commit your changes first or omit
--use-timestamp flag."
+ exit 1
+ fi
+fi
+
echo "Packaging CloudStack..."
packaging "$PACKAGEVAL" "$SIM" "$TARGETDISTRO" "$RELEASE" "$BRANDING"
"$USE_TIMESTAMP"
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services