Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,749
Community Members
 
Community Events
176
Community Groups

How do I trigger a bitbucket pipeline using API request?

Edited

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

@Theodora Boudale  it's not working because of  our repo under VPN  ,

Api request working fine from local when we connected with vpn

But we want make request from bitbucket pipeline then it's not working
Because requester(bitbucket pipeline )have different ip not vpn ip
We are using bitbucket host

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events