Biutbucket server Rest API - look up pull requests with specific commit - bitbucket

Bitbucket has a remote merge facility. In the event that a target branch already contains the commits in a pull request, the PR will be remotely merged.  I would like to determine which pull requests contain a commit so I can determine which approved pull requests led to the remote merge status.
From the API docs, I can use GET /rest/api/latest/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/commits to identify the commits. Is there a reverse operation that shows pull requests for a specific commit?
I am not finding the info in the API page here: https://developer.atlassian.com/server/bitbucket/rest/v807/

Related

Bitbucket endpoint for all Pull Requests assigned to a user?

Using the Bitbucket REST API, I’m looking for a way to get all pull requests that are assigned to a user. So far this endpoint: https://api.bitbucket.org/2.0/repositories/{workspace}/{repository_name}/pullrequests/{pullrequest_id}?fields=reviewers will show me the reviewer assigned to that specific pull request ID. Is there a way to do that, but not for a specific pull request, rather all pull requests assigned to a user?

Prevent GitHub Webhook being sent from Pushing of Tag

I am having an issue with my Jenkins pipeline that pushes a tag as one of the steps, this ultimately kicks off the build again causing a loop.
Doesn't GitHub have a way of only sending a webhook with a source commit to the repo and not a tag?
When you register for a given type of webhook with GitHub, you get notifications for every webhook of that type. Filtering is not possible for efficiency reasons, since GitHub sends massive numbers of webhook payloads. The assumption is that your service will discard any events you don't care about.
If you don't want Jenkins to build when a tag is pushed, then configure it not to do that. From some quick Googling, it appears you can control the refs to be built, so you may want to configure it to just build refs/heads/*, which doesn't include tags.

Pull request policies - Build expires after another pull request was completed. Way to automatically rerun expired builds for other PRs?

This is somewhat similar to Pull request policies - Build expired - How can I run the build again? but looks at the automation side.
Our context: We have pull requests which protect our master branch and each completed pull requests expires the builds of all other pull requests to ensure that the builds of all of the remaining pull requests have to be re-queued and build and test correctly.
Now we have times where we get pull request contention (I am looking at you, end-of-sprint!) in these times we have plenty of pull requests open. While we are working on minimizing the amount, it sometimes just happens.
Is there a plugin or some feature I am missing that actually can trigger all of those expired builds after a PR completes automatically? There is a way to automatically expire all other PR builds, so I would have thought that there is also a way to re-queue them automatically. I know this might trigger a build cascade but I would like to have my PRs always as up-to-date as possible.
Related REST API is not documented, however you can track it by tools such as Fiddler or press F12 in Chrome browser then select Network.
In the pull request page to manually queue the build as mentioned in your question.
For example with my azure devops service, I get below API
Post https://dev.azure.com/patricklu/_apis/Contribution/dataProviders/query/project/a72e1ef5-4921-49c5-9260-e72b7bff977d
Request Body:
{"contributionIds":["ms.vss-code-web.pull-request-detail-policy-data-provider"],"context":{"properties":{"repositoryId":"357893bf-9a1f-4ee4-95d3-c5ceda4f4abc","pullRequestId":12,"policyEvaluationIds":["bca44f9f-268f-4640-aa7e-af5253b3b11e"],"pageSource":{"contributionPaths":["VSS","VSS/Resources","q","knockout","mousetrap","mustache","react","react-dom","react-transition-group","jQueryUI","jquery","OfficeFabric","tslib","#uifabric","VSSUI","ContentRendering","ContentRendering/Resources","TFSUI","TFSUI/Resources","WidgetComponents","WidgetComponents/Resources","Charts","Charts/Resources","TFS","Notifications","Presentation/Scripts/marked","Presentation/Scripts/URI","Presentation/Scripts/punycode","Presentation/Scripts/IPv6","Presentation/Scripts/SecondLevelDomains","highcharts","highcharts/highcharts-more","highcharts/modules/accessibility","highcharts/modules/heatmap","highcharts/modules/funnel","Analytics"],"diagnostics":{"sessionId":"8277adc6-6810-4cf9-b984-10860e90c0b5","activityId":"8277adc6-6810-4cf9-b984-10860e90c0b5","bundlingEnabled":true,"cdnAvailable":true,"cdnEnabled":true,"webPlatformVersion":"M156","serviceVersion":"Dev17.M156.1 (build: AzureDevOps_M156_20190821.17)"},"navigation":{"topMostLevel":8,"area":"","currentController":"Apps","currentAction":"ContributedHub","currentParameters":"12","commandName":"Git.pullrequest","routeId":"ms.vss-code-web.pull-request-review-route","routeTemplates":["{project}/{team}/_git/{GitRepositoryName}/pullrequest/{parameters}","{project}/_git/{GitRepositoryName}/pullrequest/{parameters}","_git/{project}/pullrequest/{parameters}"],"routeValues":{"project":"GITAgile","parameters":"12","controller":"Apps","action":"ContributedHub","vctype":"git","viewname":"pull-request-review"}},"project":{"id":"a72e1ef5-4921-49c5-9260-e72b7bff977d","name":"GITAgile"},"selectedHubGroupId":"ms.vss-code-web.code-hub-group","selectedHubId":"ms.vss-code-web.pull-request-hub","url":"https://dev.azure.com/patricklu/_git/GITAgile/pullrequest/12?_a=overview"},"sourcePage":{"url":"https://dev.azure.com/patricklu/_git/GITAgile/pullrequest/12?_a=overview","routeId":"ms.vss-code-web.pull-request-review-route","routeValues":{"project":"GITAgile","parameters":"12","controller":"Apps","action":"ContributedHub","vctype":"git","viewname":"pull-request-review"}}}}}
As you can see there is some value such as repository ID and pull Request ID. Follow this, you should be able to user API to rerun some builds for a specific Pull Request.
You could use Azure DevOps Services service hooks or Rest API to track pull request completed or not, then use above API call to re-run the build. Hope this helps.

Deny pull requests into specific branch in TFS

I need to deny creating pull requests into specific branch for a certain group of users.
They are already set as a group in TFS, that group has been set "Deny" permission for "Contribute" to that specific branch - however its members are still able to create pull requests.
Am I doing something wrong?
Users with "Contribute" permission in a branch can push new commits to the branch and lock the branch. This permission doesn't control creating pull requests.
There is no permission to control creating pull requests on branch level, you can only control creating pull requests on Repo level, check the following screenshot:
You can only use branch policy to protect your Git branch, but deny creating pull requests into specific branch is not an option.

Bitbucket: How to not see pull requests that I have already approved

Under the Pull Requests to Review section of Bitbucket, it shows all of the pull requests that I am a reviewer of. How do I alter this so that when I approve a pull request, it no longer shows up under this section?
If this is Bitbucket Cloud (bitbucket.org), then there's an option on the dashboard for this:
Look to the right of the "Your work" label, and just above the list of pull requests, for the option.

Resources