This is my first foray into bitbucket pipelines.
In summary, when a pull request is created, I want a pipeline to decline the PR if it has no changes and merge the PR if there are changes. And only target source branches starting with a specific name.
Basically, the curl API calls do not work, they appear to return nothing. I have also tried using bearer token authorization where I created an Access token in the repository settings and copied that token into a repository variable and used that variable.
Is there a git command I could use to decline/merge the PR without credentials/API?
Hopefully the YML content renders correctly.
Thanks in advance for your help.
pull-requests: '**': - step: name: Check PR Source Branch script: - if [[ ! $BITBUCKET_BRANCH == blah-* ]]; then echo "Skipping PR not from blah branch"; exit 0; fi - step: name: Check for Changes script: - git fetch origin $BITBUCKET_PR_DESTINATION_BRANCH - git diff --exit-code origin/$BITBUCKET_PR_DESTINATION_BRANCH || echo "Changes detected" - if git diff --exit-code origin/$BITBUCKET_PR_DESTINATION_BRANCH; then echo "No changes detected, declining PR"; RESPONSE=$(curl -X POST -u $BITBUCKET_USERNAME:$BITBUCKET_APP_PASSWORD https://api.bitbucket.org/2.0/repositories/$BITBUCKET_REPO_OWNER/$BITBUCKET_REPO_SLUG/pullrequests/$BITBUCKET_PR_ID/decline) echo "RESPONSE = [$RESPONSE]" exit 1; fi - step: name: Merge PR script: - echo "Changes detected, merging PR"; - RESPONSE=$(curl -X POST -u $BITBUCKET_USERNAME:$BITBUCKET_APP_PASSWORD https://api.bitbucket.org/2.0/repositories/$BITBUCKET_REPO_OWNER/$BITBUCKET_REPO_SLUG/pullrequests/$BITBUCKET_PR_ID/merge) - echo "RESPONSE = [$RESPONSE]"