Skip to content

Instantly share code, notes, and snippets.

@igordrnobrega
Last active November 5, 2020 21:57
Show Gist options
  • Select an option

  • Save igordrnobrega/f7db022c7e1d54ee4305e05fefa7600c to your computer and use it in GitHub Desktop.

Select an option

Save igordrnobrega/f7db022c7e1d54ee4305e05fefa7600c to your computer and use it in GitHub Desktop.
circleci-trigger.fish
#!/usr/bin/env fish
function usage
echo "Triggers a CircleCI workflow."
echo
echo "Usage:"
echo " circleci-trigger <project> <branch>"
echo
echo "Arguments:"
echo " <project> The project in which the workflow will be trigger"
echo " <branch> The branch that will be used for that workflow"
end
set vcs "github"
set organization "credijusto"
set project $argv[1]
set branch $argv[2]
if test -z "$project" || test -z "$branch"
usage
exit 1
end
curl \
-H "Circle-Token: $CIRCLE_API_USER_TOKEN" \
-X POST https://circleci.com/api/v2/project/$vcs/$organization/$project/pipeline \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'x-attribution-login: string' \
-H 'x-attribution-actor-id: string' \
-d "{\"branch\":\"$branch\"}" | jq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment