CircleCI-Archived / api-preview-docs

In-progress docs about the pre-release preview of CircleCI API v2
72 stars 39 forks source link

Desired: Run a pipeline on a specified branch #30

Closed tahir-wasim closed 4 years ago

tahir-wasim commented 5 years ago

Currently we have an endpoint to which you can make a POST request: POST /project/:project_slug/pipeline. This runs a pipeline on a default branch. Is it possible to run a pipeline on a specified branch, using the 1.1 structure? eg. POST /project/:project_slug/tree/:branch/pipeline

sulami commented 5 years ago

You can include a payload on the v2 post request like this:

{“branch”: “feature/foo”}

And that will trigger a pipeline for the branch you name instead of the default branch.

Robin Schroer On 28 Jun 2019, 21:33 +0200, Tahir Wasim notifications@github.com, wrote:

Currently we have an endpoint to which you can make a POST request: POST /project/:project_slug/pipeline. This runs a pipeline on a default branch. Is it possible to run a pipeline on a specified branch, using the 1.1 structure? eg. POST /project/:project_slug/tree/:branch/pipeline — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

sulami commented 5 years ago

I'm not sure why this isn't showing on GitHub, but I checked on our current cloud environment, and it indeed works as intended for my test repo. The exact request I'm sending is this:

curl -i -H Circle-Token\:\ -H Accept\:\ application/json -H Content-Type\:\ application/json -XPOST https\://circleci.com/api/v2/project/github/sulami/cci-test/pipeline -d {' '\ \ \"branch\"\:\ \"foobar\"\,' '}' '

Sorry about the crazy escaping, this code is generated, but I confirmed it works if you just paste it into a shell.

--

Robin Schroer On 1 Jul 2019, 14:31 +0200, KhadijaAmmar notifications@github.com, wrote:

You can include a payload on the v2 post request like this: {“branch”: “feature/foo”} And that will trigger a pipeline for the branch you name instead of the default branch. Robin Schroer … On 28 Jun 2019, 21:33 +0200, Tahir Wasim @.***>, wrote: Currently we have an endpoint to which you can make a POST request: POST /project/:project_slug/pipeline. This runs a pipeline on a default branch. Is it possible to run a pipeline on a specified branch, using the 1.1 structure? eg. POST /project/:project_slug/tree/:branch/pipeline — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread. Are you sure it will trigger on a specific branch? that doesn't work for me and it's always triggering the default branch — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.