Skip to content

Commit

Permalink
User pipelines run endpoint for api trigger (#9133)
Browse files Browse the repository at this point in the history
* update api trigger steps to use project slug and recommand for all users (not gitlab)

* add in legacy steps again for server

* Update jekyll/_cci2/triggers-overview.adoc

Co-authored-by: BeFunes <benedetta@circleci.com>

* add note that new endpoint is recommended

---------

Co-authored-by: BeFunes <benedetta@circleci.com>
  • Loading branch information
rosieyohannan and BeFunes authored Dec 13, 2024
1 parent ff603fc commit f5defb2
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions jekyll/_cci2/triggers-overview.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ TIP: If your code is integrated via **GitHub OAuth or Bitbucket Cloud**, you can

NOTE: Triggering a pipeline via the CircleCI v2 API is not currently supported for GitLab projects.

[.tab.apitrigger.GitHub_App_/_Bitbucket_Data_Center]
[.tab.trigger-pipeline-api.GitHub_and_Bitbucket]
--
For **projects integrated with GitHub App or Bitbucket Data Center**, you can trigger a pipeline for a project using the link:https://circleci.com/docs/api/v2/index.html#tag/Pipeline/operation/triggerPipelineRun[v2 API endpoint] `https://circleci.com/api/v2/project/circleci/<org-id>/<project-id>/pipeline/run`.
This method is supported for GitHub (OAuth and App) and Bitbucket (Cloud and Data Center) orgs.

TIP: **GitHub OAuth and Bitbucket Cloud pipelines** can also be triggered using the link:https://circleci.com/docs/api/v2/index.html#operation/triggerPipeline[Trigger a New Pipeline] endpoint, which is described in the **CircleCI server** tab. However, the method outlined in this section is recommended.

Trigger a pipeline for a project using the link:https://circleci.com/docs/api/v2/index.html#tag/Pipeline/operation/triggerPipelineRun[v2 API endpoint] `https://circleci.com/api/v2/project/<project-slug>/pipeline/run`.

. If you have not already, get set up to use API v2 by following the steps in the <<api-developers-guide#authentication-and-authorization,API Developers Guide>>.

. In the link:https://app.circleci.com/home/[CircleCI web app] select your organization. Over the next few steps you will collect the data you need to trigger your pipeline.

. Find your organization ID:
.. Select **Organization Settings** in the CircleCI web app sidebar.
.. Copy and your organization ID. Save this somewhere, you will need it later.

. Find your project ID:
. Find your project slug:
.. Select **Projects** in the CircleCI web app sidebar.
.. Find your project.
.. Select the ellipsis menu (icon:ellipsis-h[ellipsis]) and choose **Project Settings**.
.. Copy your project ID. Save this somewhere, you will need it later.
.. Copy your project slug. Save this somewhere, you will need it later.

. Find your definition ID:
.. You should be in project settings if you are following these steps in sequence. If not see previous steps to get there. Select **Pipelines** in the sidebar.
Expand All @@ -82,7 +82,7 @@ image::triggers/copy-pipeline-definition-id.png[screenshot showing location of p
+
[source,shell]
----
curl -X POST https://circleci.com/api/v2/project/circleci/<org-id>/<project-id>/pipeline/run \
curl -X POST https://circleci.com/api/v2/project/<project-slug>/pipeline/run \
--header "Circle-Token: $CIRCLE_TOKEN" \
--header "content-type: application/json" \
--data '{
Expand All @@ -103,17 +103,17 @@ curl -X POST https://circleci.com/api/v2/project/circleci/<org-id>/<project-id>/
. Head back to the CircleCI web app and see your pipeline running on the dashboard.
--

[.tab.apitrigger.GitHub_OAuth_app_/_Bitbucket_Cloud]
[.tab.trigger-pipeline-api.CircleCI_server]
--
For **projects integrated with GitHub OAuth app or Bitbucket Cloud**, you can trigger a pipeline for a project using the link:https://circleci.com/docs/api/v2/index.html#operation/triggerPipeline[Trigger a New Pipeline] endpoint.

. If you have not already, get set up to use API v2 by following the steps in the <<api-developers-guide#authentication-and-authorization,API Developers Guide>>.

. To trigger a pipeline from the command line using `curl`, copy and paste this sample request and replace the details in `< >` with your details, VCS can be `gh` or `bb`:
+
NOTE: If you are using CircleCI cloud, <your-circleci-hostname> should be `circleci.com`.
+
[source,shell]
----
curl -X POST https://circleci.com/api/v2/project/<VCS>/<your-vcs-org-or-username>/<your-repo-name>/pipeline \
curl -X POST https://<your-circleci-hostname>/api/v2/project/<VCS>/<your-vcs-org-or-username>/<your-repo-name>/pipeline \
--header "Circle-Token: $CIRCLE_TOKEN" \
--header "content-type: application/json" \
--data '{"branch":"<your-branch-name>"}'
Expand Down

0 comments on commit f5defb2

Please sign in to comment.