Step that triggers pipeline in different project

You may have situations where a specific workflow in one of your projects should trigger a new build in a different project. As an example, maybe an update to your blog project needs to kick off a new build in your website project to ensure everything is up to date.

You can accomplish this via a run step that sends an API call to trigger a new pipeline. You will want to generate a personal API token and store it as an environment variable within the project the run step will be on.

Then once that is done you will add this run step to your config of that project:

- run:
  name: Kick off new pipeline
  command: |
    curl --location --request POST 'https://circleci.com/api/v2/project/(vcs)/(org)/(project)/pipeline' \
    --header 'Content-Type: application/json' \
    -u "${API_TOKEN}:"

In the above snippet, you will need to update (vcs) to github or bitbucket, (org) to your Organization, and (project) to the name of your project.

Was this article helpful?
1 out of 2 found this helpful

Comments

0 comments

Article is closed for comments.