How to programmatically set up a CircleCI project

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:

  1. Retrieve the personal API token (see prerequisites)
  2. 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"

      }'

 

Outcome:

If the operation is successful, you'll receive a 200 response.

 

Additional Resources:

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.