Introduction:
Usually, setting up a project is done via the CircleCI UI. However, you might have a use-case that requires or benefits from automating the setup process.
You can programmatically set up a CircleCI project by leveraging the "Follow a New Project on CircleCI" API v1 endpoint.
Prerequisites:
If you don't already have one that you can use, you'll need to generate a personal API token for a user who has, at least, write
access on the related project.
Instructions:
- Retrieve the personal API token (see prerequisites)
-
Programmatically set up the project
- The following example uses cURL+shell but you can wrap the API call and use it with your favourite language.
curl --location --request POST 'https://circleci.com/api/v1.1/project/<VCS>/<ORG_NAME>/<NEW_REPO_NAME>/follow' \
--header 'Content-Type: application/json' \
-u '<API_TOKEN>:' \
--data-raw '{
"first_build": "true"
}'
- The following example uses cURL+shell but you can wrap the API call and use it with your favourite language.
Outcome:
If the operation is successful, you'll receive a 200
response.
Comments
Article is closed for comments.