Hello,
Do anyone know how to get the pull request ID based on the commit's hash?
I'm triggering a jenkins job via http webhook. Once the job ends, if there is a problem I want to mark the PR as "needs work".
I've found a working API call (https://docs.atlassian.com/bitbucket-server/rest/6.0.2/bitbucket-rest.html#idp288) but I need to provide the PR ID.
Unfortunately the HTTP webhook plugin does not provide such property.
I realize it is not quite the answer you requested, but do you use or have you considered using multi-branch pipelines in Jenkins? With multi-branch pipelines, you are automatically hooked into BitBucket such that the failed build will cause the failure to be seen on the BitBucket PR and you can readily have your merge checks 'block' on that failure as in users have to get the job passing before the PR can be merged.
You can also then do more custom behavior if desired, including getting the PR ID from the Jenkins CHANGE_ID and BRANCH_NAME environment variables and sending info to that API endpoint if the built-in hooks are insufficient for your needs.
I really don't see any env variable CHANGE_ID when the job runs, I checked by printing all the env variables available during the build.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Have you found a way so far?
I also need PR ID for a similar use case.
Many Thanks in advance!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any update on this on how to get the PR ID ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.