aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-05-12 21:27:47 -0700
committerGravatar MarkKoz <[email protected]>2019-05-12 21:29:52 -0700
commitd3ebab35364e1c574acce3c8fe4a363dcacbe6c8 (patch)
treee2b0b95e84ac0c01e61692e85c35d7191befcdf4
parentUse eq() function in conditions instead of relying on casts (diff)
Make the JSON regex more robust
-rw-r--r--azure-pipelines.yml4
1 files changed, 2 insertions, 2 deletions
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index ea6ad8b..bfd132f 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -52,13 +52,13 @@ jobs:
RESPONSE="$(curl -sSL "${REQUEST_URL}")"
if [[ $BUILD_REASON = "PullRequest" ]]; then
- PREV_COMMIT="$(echo "${RESPONSE}" | grep -Po '"pr.sourceSha":"\K.*?[^\\](?=",)')"
+ PREV_COMMIT="$(echo "${RESPONSE}" | grep -Po '"pr\.sourceSha"\s*:\s*"\K.*?[^\\](?="\s*[,}])')"
if [[ -z $PREV_COMMIT ]]; then
echo "Could not retrieve the previous build's commit. Falling back to the head of the target branch."
PREV_COMMIT="origin/$SYSTEM_PULLREQUEST_TARGETBRANCH"
fi
else
- PREV_COMMIT="$(echo "${RESPONSE}" | grep -Po '"sourceVersion":"\K.*?[^\\](?=",)')"
+ PREV_COMMIT="$(echo "${RESPONSE}" | grep -Po '"sourceVersion"\s*:\s*"\K.*?[^\\](?="\s*[,}])')"
fi
if [[ -n $PREV_COMMIT ]]; then