nishio-dens / bitbucket-pullrequest-builder-plugin

Bitbucket Pull Request Builder Plugin for Jenkins
Other
125 stars 145 forks source link

Commenting for a rebuild checks out latest branch, not the source for the PR #220

Open kevingardner opened 4 years ago

kevingardner commented 4 years ago

Hey all, we're having issues with rebuilding pull requests based on comment. Currently, our Jenkins job will check out the most updated branch regardless of what the source branch for the PR we comment on for a rebuild.

For example, we have a PR with a source branch of alb-asg with a target branch of development, and when we comment on that PR for a rebuild, the most updated branch, in this case cfn-init, is pulled instead and built. The Jenkins job status screen shows the correct PR but the incorrect branch.

We've tried wiping the plugin config, downgrading the plugin, but we still have this same issue.

CodeMonk commented 4 years ago

The plugin technically builds the commit hash. Is that particular hash in the other branch that gets built?

On Mon, Mar 23, 2020 at 9:29 AM Kevin Gardner notifications@github.com wrote:

Hey all, we're having issues with rebuilding pull requests based on comment. Currently, our Jenkins job will check out the most updated branch regardless of what the source branch for the PR we comment on for a rebuild.

For example, we have a PR with a source branch of alb-asg with a target branch of development, and when we comment on that PR for a rebuild, the most updated branch, in this case cfn-init, is pulled instead and built. The Jenkins job status screen shows the correct PR but the incorrect branch.

We've tried wiping the plugin config, downgrading the plugin, but we still have this same issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nishio-dens/bitbucket-pullrequest-builder-plugin/issues/220, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA72VUVXDTQBAAH7U6KSSDRI555RANCNFSM4LR6URAA .

kevingardner commented 4 years ago

The plugin technically builds the commit hash. Is that particular hash in the other branch that gets built? On Mon, Mar 23, 2020 at 9:29 AM Kevin Gardner @.***> wrote: Hey all, we're having issues with rebuilding pull requests based on comment. Currently, our Jenkins job will check out the most updated branch regardless of what the source branch for the PR we comment on for a rebuild. For example, we have a PR with a source branch of alb-asg with a target branch of development, and when we comment on that PR for a rebuild, the most updated branch, in this case cfn-init, is pulled instead and built. The Jenkins job status screen shows the correct PR but the incorrect branch. We've tried wiping the plugin config, downgrading the plugin, but we still have this same issue. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#220>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA72VUVXDTQBAAH7U6KSSDRI555RANCNFSM4LR6URAA .

Yes the particular hash is in the other branch that gets built.

The PR that is triggering the plugin and the commit that is being checked out belong to two separate branches.

CodeMonk commented 4 years ago

If the same commit hash is in two different branches, then, other than the branch name, they're identical. The plugin does NOT check out a branch, it checks out and builds a particular hash. The sourceBranch and targetBranch are there for convenience, but, they have nothing to do with a build.

Can you please paste a picture of the status that you're talking about? If something incorrect is being displayed, then we can absolutely try to fix that.

But, again, the build itself, after it is kicked off by the PR builder, will always build a hash, not a branch -- but we do need to make sure we're displaying things properly.

kevingardner commented 4 years ago

The commit exists in just one branch. What's happening is that the most recently pushed commit is what is always being checked out and built, regardless of what PR we comment on. For example, we have a PR open, 353, with a source branch of taskcat-pr-test and a destination branch of taskcat-cft-tests. The latest commit to taskcat-refactor is bf54:

prtestcommit

When we look at Jenkins, we can see the plugin has pulled in the correct PR, 353, but it's pulled in (at the time) the most recently pushed commit which is on a different branch.

jenkinsstatus

If we look at the job log, we see that same commit, eaa53, being checked out:

17:13:22 JENKINS-19022: warning: possible memory leak due to Git plugin usage; see: https://wiki.jenkins.io/display/JENKINS/Remove+Git+Plugin+BuildsByBranch+BuildData 17:13:22 Checking out Revision eaa53 (origin/eksvrersion) 17:13:22 > git config core.sparsecheckout # timeout=10 17:13:22 > git checkout -f eaa53 # timeout=10 17:13:22 Commit message: "eks version param added" 17:13:22 > git rev-list --no-walk eaa53 # timeout=10 17:13:22 No emails were triggered. 17:13:22 [CF Templates - PR Test] $ /bin/sh -xe /tmp/jenkins2993714649873802381.sh 17:13:22 + echo Source branch: taskcat-pr-test 17:13:22 Source branch: taskcat-pr-test 17:13:22 + echo Target branch: taskcat-cft-tests 17:13:22 Target branch: taskcat-cft-tests 17:13:22 + '[' -d test ']' 17:13:22 + cd test 17:13:22 ++ git diff --name-only origin/master 17:13:22 ++ egrep '^Verisk.+.yaml$' 17:13:22 + for p in '$(git diff --name-only origin/master | egrep '\''^Verisk.+.yaml$'\'')' 17:13:22 ++ basename -s .yaml EKS_Cluster_Template.yaml 17:13:22 + base=EKS_Cluster_Template 17:13:22 + '[' -d EKS_Cluster_Template']' 17:13:22 + echo 'No test scaffolding for EKS_Cluster_Template.yaml exists, write some tests!' 17:13:22 No test scaffolding for Verisk_EKS_Cluster_Template.yaml exists, write some tests!

Here is our plugin configuration for the job:

jenkinsjob

CodeMonk commented 4 years ago

So, in the logs I saw the PR trying to do approvals. That approve button is not clicked. That seems very strange.

Also, is this bitbucket server? I was assuming cloud. I have no idea how server works or does not work, and I've been assuming bitbucket cloud.

CodeMonk commented 4 years ago

BTW - I do not have the bitbucket URL populated on my config, and, I thought that was only used for bitbucket server.