Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User pipelines run endpoint for api trigger #9133

Merged
merged 5 commits into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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