Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I trigger a bitbucket pipeline using API request?

Edited
Ishan Roy I'm New Here Aug 19, 2021

I am trying to trigger a bitbucket pipeline using the api endpoint, but I am getting the following response: 
{
"error": {
"message": "Bad request",
"detail": "bitbucket-pipelines.yml not found.",
"data": {
"key": "result-service.pipeline.yml-not-found",
"arguments": {}
}
}
}

This is the request that I am using. I have verified and this branch has the pipeline and I am able to trigger it manually from pipelines section of the repo.

curl -X POST -is -u username:password \
-H 'Content-Type: application/json' \
https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines/ \
-d '
{
"target": {
"ref_type": "branch",
"type": "pipeline_ref_target",
"ref_name": "branchname"
},
"variables": [
{
"key": "key1",
"value": "value1"
},
{
"key": "key2",
"value": "value2"
}]
}'


1 answer

1 accepted

0 votes
Answer accepted

Hi @Ishan Roy and welcome to the community.

The data you need to send with the request depends on the type of the pipeline you want to trigger.

The documentation below has some examples:

Is the pipeline you want to trigger defined as follows

pipelines:
branches:
branchname:

in the bitbucket-pipelines.yml file of this branch? Or is it perhaps a custom pipeline? In case it's a custom pipeline, you'll need to include some additional fields in the request (you can check the examples in the doc).

We'd need to know in which section of your bitbucket-pipelines.yml file this pipeline is defined in order to figure out how it should get triggered.

Kind regards,
Theodora

Hi @Theodora Boudale, It was a custom pipeline and I was able to trigger the same after adding the selector in the request body. Thanks for the support. 

{
"target": {
"ref_type": "branch",
"type": "pipeline_ref_target",
"ref_name": "master",
"selector": {
"type": "custom",
"pattern": "Name"
}
}
}

Thanks and Regards,
Ishan Roy
Like Theodora Boudale likes this

Thank you for the update @Ishan Roy and you are very welcome, I'm glad to have helped!

Please feel free to reach out if you ever need anything else.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

221 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you