@@ -258,47 +258,7 @@ jobs:
258258 - run :
259259 name : Trigger pipelines
260260 command : |
261- for PIPELINE in << parameters.pipelines_to_trigger >> ; do
262- echo "Triggering pipeline with source $PIPELINE"
263- EVENT_ID=`curl -s -X POST -H "content-type: application/json" -d "{ }" http://spinnaker/api/v1/webhooks/webhook/$PIPELINE | jq -r .eventId`
264- echo "eventId: $EVENT_ID"
265- sleep 5 # Let pipeline start
266- PASS=`cat ~/.hal/default/profiles/gate-local.yml | grep password`
267- PASS=${PASS#*:\ }
268- USER=`cat ~/.hal/default/profiles/gate-local.yml | grep name`
269- USER=${USER#*:\ }
270- ALL_APPS=`curl -s -X GET --user "$USER:$PASS" "http://spinnaker/api/v1/applications" | jq -r .[].name`
271- MAX_ATTEMPTS=20
272- for APP in $ALL_APPS ; do
273- PIPELINE_NAME=`curl -s -X GET --user "$USER:$PASS" "http://spinnaker/api/v1/applications/$APP/executions/search?triggerTypes=webhook&eventId=$EVENT_ID" | jq -r .[].name`
274- ATTEMPTS=0
275- while [[ $PIPELINE_NAME != "" ]] && [ $ATTEMPTS -lt $MAX_ATTEMPTS ] ; do
276- echo "Checking pipeline $PIPELINE_NAME status"
277- STATUS=`curl -s -X GET --user "$USER:$PASS" "http://spinnaker/api/v1/applications/$APP/executions/search?triggerTypes=webhook&eventId=$EVENT_ID" | jq -r .[].status`
278- if [ -n $STATUS ] && [[ $STATUS == "NOT_STARTED" ]] ; then
279- echo "Waiting for pipeline $PIPELINE_NAME to start"
280- sleep 3
281- elif [ -n $STATUS ] && [[ $STATUS == "RUNNING" ]] ; then
282- echo "Waiting for pipeline $PIPELINE_NAME to finish"
283- sleep 3
284- elif [ -n $STATUS ] && [[ $STATUS != "SUCCEEDED" ]] ; then
285- echo "Pipeline $PIPELINE_NAME exited with status $STATUS"
286- exit 1
287- elif [ -n $STATUS ] && [[ $STATUS == "SUCCEEDED" ]] ; then
288- echo "$Pipeline PIPELINE_NAME succeded"
289- break
290- else
291- echo "Status of pipeline is: $STATUS"
292- exit 1
293- fi
294- ((++ATTEMPTS))
295- done
296- if [ $ATTEMPTS -ge $MAX_ATTEMPTS ] ; then
297- echo "Check timed out"
298- exit 1
299- fi
300- done
301- done
261+ .circleci/libs/trigger-pipelines.sh << parameters.pipelines_to_trigger >>
302262
303263workflows :
304264 periodic :
0 commit comments