Open
Conversation
b4e1a93 to
a98671e
Compare
wurbanski
suggested changes
Jun 5, 2020
.circleci/config.yml
Outdated
Comment on lines
261
to
301
| 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" | ||
| sleep 5 # Let pipeline start | ||
| 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 | ||
| 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 == "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 PIPELINE_NAME succeded" | ||
| break | ||
| else | ||
| echo "Status of pipeline is: $STATUS" | ||
| exit 1 | ||
| fi | ||
| ((++ATTEMPTS)) | ||
| done | ||
| if [ $ATTEMPTS -ge $MAX_ATTEMPTS ] ; then | ||
| echo "Check timed out" | ||
| exit 1 | ||
| fi | ||
| done | ||
| done |
Contributor
There was a problem hiding this comment.
Can you move this to a script? You can store it in .circleci directory.
Author
There was a problem hiding this comment.
I did.
But I have no idea, why there is such behaviour:
When executed by cirleci, it's not entering the while loop (not printing Checking pipeline $PIPELINE_NAME status; PIPELINE_NAME probably equals ""), but when I rerun job with ssh, and execute script from terminal on machine, it iterates. Do you have any suggestions?
feaf44f to
54e1faa
Compare
c5dbd11 to
446f514
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added possibility to trigger pipelines in spinnaker
Granted to spinnaker privileges to deploy to kind