Skip to content

Commit

Permalink
Usefull prints, handling of NOT_STARTED and RUNNING pipeline status
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalparadowski committed Jun 5, 2020
1 parent 33d816d commit a98671e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
26 changes: 19 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,30 +259,42 @@ jobs:
name: Trigger pipelines
command: |
for PIPELINE in << parameters.pipelines_to_trigger >> ; do
echo "Triggering pipeline with source $PIPELINE"
EVENT_ID=`curl -s -X POST -H "content-type: application/json" -d "{ }" http://spinnaker/api/v1/webhooks/webhook/$PIPELINE | jq -r .eventId`
echo "eventId: $EVENT_ID"
PASS=`cat ~/.hal/default/profiles/gate-local.yml | grep password`
PASS=${PASS#*:\ }
USER=`cat ~/.hal/default/profiles/gate-local.yml | grep name`
USER=${USER#*:\ }
ALL_APPS=`curl -s -X GET --user "$USER:$PASS" "http://spinnaker/api/v1/applications" | jq -r .[].name`
MAX_ATTEMPTS=20
for APP in ALL_APPS ; do
for APP in $ALL_APPS ; do
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`
ATTEMPTS=0
while [[ $PIPELINE_NAME != "" ]] && [ $ATTEMPTS -lt $MAX_ATTEMPTS ] ; do
echo "Checking pipeline $PIPELINE_NAME status"
STATUS=`curl -s -X GET --user "$USER:$PASS" "http://spinnaker/api/v1/applications/$APP/executions/search?triggerTypes=webhook&eventId=$EVENT_ID" | jq -r .[].status`
if [ -n $STATUS ] && [[ $STATUS != "SUCCEEDED" ]] ; then
echo "$PIPELINE_NAME exited with status $STATUS"
if [ -n $STATUS ] && [[ $STATUS == "NOT_STARTED" ]] ; then
echo "Waiting for pipeline $PIPELINE_NAME to start"
sleep 3
elif [ -n $STATUS ] && [[ $STATUS == "RUNNING" ]] ; then
echo "Waiting for pipeline $PIPELINE_NAME to finish"
sleep 3
elif [ -n $STATUS ] && [[ $STATUS != "SUCCEEDED" ]] ; then
echo "Pipeline $PIPELINE_NAME exited with status $STATUS"
exit 1
elif [ -n $STATUS ] && [[ $STATUS == "SUCCEEDED" ]] ; then
echo "$PIPELINE_NAME succeded"
echo "$Pipeline PIPELINE_NAME succeded"
break
else
echo "Waiting for pipeline $PIPELINE_NAME to finish"
sleep 3
echo "Status of pipeline is: $STATUS"
exit 1
fi
((ATTEMPTS++))
((++ATTEMPTS))
done
if [ $ATTEMPTS -lt $MAX_ATTEMPTS ] ; then
echo "Check timed out"
fi
done
done
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/pipelines/deployNginx.jsonnet
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local pipelines = import 'pipeline.libsonnet';

local deployment = import 'deploy.json';
local deployment = import 'deployNginx.json';

local app = "jsonnetapp";
local webhookTrigger(name, source) = pipelines.triggers
Expand Down

0 comments on commit a98671e

Please sign in to comment.