jenkinsci / bitbucket-push-and-pull-request-plugin

Plugin for Jenkins v2.138.2 or later, that triggers job builds on Bitbucket's push and pull request events.
https://plugins.jenkins.io/bitbucket-push-and-pull-request
MIT License
46 stars 50 forks source link

git rev-parse stderr when merging a PR with squash option + delete source branch on bitbucket. #285

Open ericfaure007 opened 1 year ago

ericfaure007 commented 1 year ago

I have a problem on a specific case:

Jenkins 2.346.3 BBPPR 2.8.3 bitbucket server v7.21.4

When merging a bitbucket PR with squash merge strategy + deleting the source branch, the jenkins job is triggered as it should but the git plugin is failing to checkout/rev-parse with the following error message:

git rev-parse xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^{commit} # timeout=10 FATAL: Command "git rev-parse xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^{commit}" returned status code 128: stdout: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^{commit}

stderr: fatal: ambiguous argument 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^{commit}': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this:

First analysis: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx is the last source branch commitID of the PR. git plugin is using it, but is failing because the commitID doesn't exist anymore. Indeed it's because the source branch is deleted (so the commitID too) and destination branch is squashed so it doesn't contain this commitID neither.

I have tried to configure/setup SCM to change the behavior of using the latest source branch commitID, but I didn't succeed. Is there a way to change that? Is there another workaround? Is BBPPR supporting squash merge strategy?