Skip to content

Instantly share code, notes, and snippets.

@kzap
Last active October 23, 2018 04:15
Show Gist options
  • Save kzap/ec30cfeaf9ed41a53b48fe5336297651 to your computer and use it in GitHub Desktop.
Save kzap/ec30cfeaf9ed41a53b48fe5336297651 to your computer and use it in GitHub Desktop.
CircleCI Force Run a Workflow via the API
#!/bin/bash
# FROM https://discuss.circleci.com/t/github-outage-on-21-october-2018/25903/8
PROVIDER=github # or bitbucket
ORG=my-project-org-or-user
PROJECT=my-project-name
if [ -z $CIRCLECI_TOKEN ]
then
echo "Create a token at https://circleci.com/account/api and export it as CIRCLECI_TOKEN."
exit 1
fi
if [ -z $1 ]
then
echo "Usage: $0 <branch>"
exit 2
fi
echo "Triggering build for branch $1..."
curl -X POST -H "Content-Type: application/json" \
-d '{"branch": "'$1'"}' \
https://circleci.com/api/v1.1/project/$PROVIDER/$ORG/$PROJECT/build\?circle-token\=$CIRCLECI_TOKEN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment