0

I have triggered a build in Jenkins after creating a new pull request in bitbucket. I want to automatically decline the pull request right away when building fail in Jenkins. How do I do it and how can I set up it.

1 Answers1

0

Is it possible to use a shell script in your case? Something like this:

 #!/usr/bin/env bash

 if test $1 -ne 0; then
 curl https://api.bitbucket.org//2.0/repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/decline \
 -u $3:$4 \
 --request POST \
 --header 'Content-Type: application/json' \
 --data '{}'
 fi

 exit $1

Then, you can call the script as:

chmod +x decline-pull-request.sh
decline-pull-request.sh $(status) $(pullRequestId) $(bitbucketUsername) $(bitbucketPassword)
Daniel Nazareth
  • 530
  • 1
  • 6
  • 22