Skip to content

Instantly share code, notes, and snippets.

@denniswebb
Last active January 29, 2018 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denniswebb/7f20ff533bdf10831fa10f591b377219 to your computer and use it in GitHub Desktop.
Save denniswebb/7f20ff533bdf10831fa10f591b377219 to your computer and use it in GitHub Desktop.
CircleCI API

Get all repos on CircleCI

curl "https://circleci.com/api/v1.1/projects?circle-token=$CIRCLE_TOKEN" | jq -r '.[] | .username + "/" + .reponame'

Set slack_webhook_url for a single repo

curl -XPUT --header "Content-Type: application/json" "https://circleci.com/api/v1.1/project/github/MyOrg/MyRepo/settings?circle-token=$CIRCLE_TOKEN" -d '{"slack_webhook_url":"https://hooks.slack.com/services/FSFDSFDS?DSFHJKHDFKJSDH"}'

Put it all together to setup webhooks for all of your repos

curl "https://circleci.com/api/v1.1/projects?circle-token=$CIRCLE_TOKEN" |  \
  jq -r '.[] | .username + "/" + .reponame' | \
  grep MyOrganization | \
  xargs -I "%" \
  curl -XPUT --header "Content-Type: application/json" \
  "https://circleci.com/api/v1.1/project/github/%/settings?circle-token=$CIRCLE_TOKEN" \
  -d '{"slack_webhook_url":"https://hooks.slack.com/services/SFDSFDS?DSFHJKHDFKJSDH"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment