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,463,706
Community Members
 
Community Events
176
Community Groups

How Can I Get Triggered Pipeline Of Pull Request?

I am using the Bitbucket API to access a pull request via its ID

```

https://api.bitbucket.org/2.0/repositories/${CONSTANTS.BITBUCKET_REPO_OWNER}/${REPO_NAME}/pullrequests/${PR_ID}

```

When a PR is merged from my "dev" branch to my "stage" branch, a pipeline is automatically triggered.

I want to know how I can get the pipeline ID of that merge. It seems that the pipeline API does not return what triggered it.

1 answer

1 vote

Hi @NZ and welcome to the community.

Pull-requests pipelines run when a PR is created or updated.

If your pipeline runs automatically when a PR is merged, then the trigger is different.
It could be either the default pipeline, or a branches pipeline for the "stage" branch.

The pipelines API has a target object for each pipeline. If the trigger was a branch pipeline, this object looks as follows:

"target": {
"type": "pipeline_ref_target",
"ref_type": "branch",
"ref_name": "develop",
"selector": {
"type": "branches",
"pattern": "develop"
},
"commit": {
"type": "commit",
"hash": "0b0be990348b6b6f433216d7c2a68b1578aa42f9",
"links": { [...]
}
}
}

If the PR is merged via a merge commit, you can get the hash of the merge commit and then query pipelines builds for that commit.
Pipelines API does not support filtering at the moment, so you could use another tool, like jq, to filter the results.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events