I am using the Bitbucket API to access a pull request via its 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.
Hi @z 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.