Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Trigger Custom Pipeline using API

Hi All,

I'm trying to trigger a custom pipeline for a particular branch using the following API call below:

curl -X POST -is -u <user>:<password> \

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

https://api.bitbucket.org/2.0/repositories/<account>/<repo>/pipelines/ \

-d ' { "target": { "ref_type": "branch", "type": "pipeline_ref_target", "ref_name": "<branch_name>" } }'

My yaml file has two paths, one is custom and the other is branch name based. The branch name based path works without issue however I'm unable to trigger the custom pipeline path without having to go the UI and doing it manually there ( I have a few repos so I don't want to constantly go back to the UI through each repo to trigger the custom path, rather script it up in a loop to fire them all off)

It ends up giving this response after posting

"Bad request", "detail": "bitbucket-pipelines.yml not found."

If I check the branch <branch_name> for that repo I can see that the bitbucket-pipelines.yml file is definitely there. Am I missing something obvious here? It makes me think the API is hitting some other branch where the file does not exist, but all branches in that repo has a bitbucket-pipelines.yml file.

1 answer

1 accepted

1 vote
Answer accepted
rgomis Atlassian Team May 23, 2019

Hey @Sidney Chen ,

How exactly are you triggering the custom pipeline? I'd suggest that you try this example, adding the selector field to specify the custom pipeline you want to run:

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": {
      "type": "pipeline_ref_target",
      "ref_type": "branch",
      "ref_name": "master",
      "selector": {
        "type": "custom",
        "pattern": "my-custom-pipeline-name"
      }
    }
  }'

More details and examples in here: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines/

Perfect! just what I was looking for @rgomis . I kept having to trigger it from the UI since I didn't realise thats how the selector field worked.

Thanks!

Suggest an answer

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

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

777 views 15 10
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