@@ -208,15 +208,15 @@ function verify_pipeline_with_poll () {
208208 pipeline_status=$( tr ' "\""' ' "\\"' <<< " $pipeline_builds" | jq .[0].status)
209209 echo " pipeline_status this iteration --> $pipeline_status "
210210 if [ " $( echo $pipeline_status | grep ' completed' ) " != " " ]; then
211- pipeline_result=$( tr ' "\""' ' "\\"' <<< " $pipeline_builds" | jq .[0].result)
212- if [ " $( echo $pipeline_result | grep ' succeeded' ) " != " " ]; then
213- echo " Successful build for pipeline id $pipeline_id !"
214- loop_result=$pipeline_result
215- break
216- else
217- echo " Expected successful build for pipeline id $pipeline_id but result is $pipeline_result "
218- exit 1
219- fi
211+ pipeline_result=$( tr ' "\""' ' "\\"' <<< " $pipeline_builds" | jq .[0].result)
212+ if [ " $( echo $pipeline_result | grep ' succeeded' ) " != " " ]; then
213+ echo " Successful build for pipeline id $pipeline_id !"
214+ loop_result=$pipeline_result
215+ break
216+ else
217+ echo " Expected successful build for pipeline id $pipeline_id but result is $pipeline_result "
218+ exit 1
219+ fi
220220 else
221221 echo " Pipeline Id $pipeline_id status is $pipeline_status . Sleeping for $poll_interval seconds"
222222 sleep $poll_interval
@@ -231,14 +231,20 @@ function verify_pipeline_with_poll () {
231231function approve_pull_request () {
232232 all_prs=$( az repos pr list --org $1 --p $2 )
233233 pr_title=$3
234- pr_exists=$( tr ' "\""' ' "\\"' <<< " $all_prs" | jq -r --arg pr_title $pr_title ' .[] | select(.title == $pr_title) | != null' )
234+
235+ pr_exists=$( echo $all_prs | jq -r --arg pr_title " $pr_title " ' .[] | select(.title == $pr_title) != null' )
235236 if [ " $pr_exists " != " true" ]; then
236237 echo " PR for '$pr_title ' not found"
237238 exit 1
238239 fi
239- pull_request_id=$( tr ' "\"" ' ' "\\" ' <<< " $all_prs" | jq -r --arg pr_title $pr_title ' .[] | select(.title == $pr_title) | .pullRequestId' )
240+ pull_request_id=$( echo $all_prs | jq -r --arg pr_title " $pr_title " ' .[] | select(.title == $pr_title) | .pullRequestId' )
240241 echo " Found pull request id $pull_request_id for '$pr_title '"
241- approve_result=$( az repos pr update --id $pull_request_id --auto-complete true -—org $1 --p $2 )
242- echo " PR $pull_request_id approved"
243- # TODO verify actually successful
242+ approve_result=$( az repos pr update --id " $pull_request_id " --auto-complete true --output json )
243+
244+ if [ " $( echo $approve_result | jq ' .mergeStatus' | grep ' succeeded' ) " != " " ]; then
245+ echo " PR $pull_request_id approved"
246+ else
247+ echo " Issue approving PR $pull_request_id "
248+ exit 1
249+ fi
244250}
0 commit comments