Trigger pipeline with API using token based authentication

Ikram Karouche December 16, 2022

Hi, Is it possible to use OAuth2.0 to trigger a pipeline like this:

 

curl --location --request POST 'https://bitbucket.org/{workspace}/{repo_slug}/pipelines/' \

--header 'Authorization: Bearer XXXXXXX' \

--header 'Content-Type: application/json' \

--data-raw '{

"target": {

"type": "pipeline_ref_target",

"ref_type": "branch",

"ref_name": "master",

"selector": {

"type": "custom",

"pattern": "my-custom-pipeline"

}

}

}'

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 19, 2022

Hi @Ikram Karouche and welcome to the community!

It is possible to use OAuth, but you also need to use the API URL in your call. So, instead of

'https://bitbucket.org/{workspace}/{repo_slug}/pipelines/'

you need to use

'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines/'

Please feel free to let me know if this works for you or if you experience any issues. If you get any errors, please post the call you are using (make sure to mask any private/sensitive values) and the output of the call, so we can better help you.

Kind regards,
Theodora

Ikram Karouche December 19, 2022

Thank you for your response, it works !

but I m not sure if I can receive automatic email notification when the triggered pipeline fails. I can't find this in the documentation.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 19, 2022

Hi,

That's good to hear and you are very welcome!

Notifications are sent if you subscribe to them.

  1. Open the repo on Bitbucket Cloud website
  2. Select the Source page
  3. On the top right-hand corner, next to the Clone link, select the 3 dots > Manage notifications
    Screenshot 2022-12-19 at 16.20.55.png
  4. Ensure that the option for Pipelines notifications is checked

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events