Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build status linked to unrelated Pull Request when 2 branches point to the same commit #877

Open
jroch opened this issue Sep 2, 2024 · 3 comments
Labels

Comments

@jroch
Copy link

jroch commented Sep 2, 2024

Jenkins and plugins versions report

Environment
Jenkins: 2.442
OS: Linux - 4.18.0-553.8.1.el8_10.x86_64
Java: 17.0.9 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
---
PrioritySorter:5.1.0
ace-editor:1.1
active-directory:2.34
allure-jenkins-plugin:2.31.1
analysis-model-api:11.15.0
ansicolor:1.0.4
antisamy-markup-formatter:162.v0e6ec0fcfcf6
apache-httpcomponents-client-4-api:4.5.14-208.v438351942757
artifact-manager-s3:845.vb_0805c11eb_26
authentication-tokens:1.53.v1c90fd9191a_b_
aws-credentials:191.vcb_f183ce58b_9
aws-global-configuration:108.v47b_fd43dfec6
aws-java-sdk-ec2:1.12.70
aws-java-sdk-minimal:1.12.215-339.vdc07efc5320c
bootstrap4-api:4.6.0-6
bootstrap5-api:5.3.2-3
bouncycastle-api:2.30.1.77-225.v26ea_c9455fd9
branch-api:2.1144.v1425d1c3d5a_7
build-monitor-plugin:1.14-826.vb_a_c11536174d
build-user-vars-plugin:1.9
caffeine-api:3.1.8-133.v17b_1ff2e0599
categorized-view:1.13
checks-api:2.0.2
cloudbees-bitbucket-branch-source:866.vdea_7dcd3008e
cloudbees-folder:6.901.vb_4c7a_da_75da_3
command-launcher:107.v773860566e2e
commons-lang3-api:3.13.0-62.v7d18e55f51e2
commons-text-api:1.11.0-95.v22a_d30ee5d36
config-file-provider:968.ve1ca_eb_913f8c
configuration-as-code:1775.v810dc950b_514
credentials:1319.v7eb_51b_3a_c97b_
credentials-binding:657.v2b_19db_7d6e6d
data-tables-api:1.13.8-2
database:191.vd5981b_97a_5fa_
database-h2:1.4.97.v8b_21e67e883a_
dependency-check-jenkins-plugin:5.4.6
dependency-track:4.3.1
display-url-api:2.200.vb_9327d658781
docker-commons:439.va_3cb_0a_6a_fb_29
docker-workflow:572.v950f58993843
durable-task:550.v0930093c4b_a_6
echarts-api:5.4.3-2
elastic-axis:464.va_7ed499b_9d75
email-ext:2.104
embeddable-build-status:467.v4a_954796e45d
extended-read-permission:53.v6499940139e5
favorite:2.208.v91d65b_7792a_c
file-parameters:316.va_83a_1221db_a_7
folder-properties:1.2.1
font-awesome-api:6.5.1-2
forensics-api:2.3.0
generic-webhook-trigger:2.0.0
git:5.2.1
git-client:4.6.0
git-server:114.v068a_c7cc2574
google-kubernetes-engine:0.429.vc265a_dc27a_6c
google-oauth-plugin:1.330.vf5e86021cb_ec
groovy:457.v99900cb_85593
gson-api:2.10.1-15.v0d99f670e0a_7
h2-api:11.1.4.199-12.v9f4244395f7a_
handy-uri-templates-2-api:2.1.8-30.v7e777411b_148
htmlpublisher:1.32
instance-identity:185.v303dc7c645f9
ionicons-api:56.v1b_1c8c49374e
jackson2-api:2.16.1-373.ve709c6871598
jakarta-activation-api:2.0.1-3
jakarta-mail-api:2.0.1-3
javadoc:243.vb_b_503b_b_45537
javax-activation-api:1.2.0-6
javax-mail-api:1.6.2-9
jaxb:2.3.9-1
jdk-tool:73.vddf737284550
job-dsl:1.87
joda-time-api:2.12.7-29.v5a_b_e3a_82269a_
jquery-detached:1.2.1
jquery3-api:3.7.1-1
jsch:0.2.16-86.v42e010d9484b_
json-api:20231013-17.v1c97069404b_e
json-path-api:2.9.0-33.v2527142f2e1d
json-validation-jenkins-plugin:1.0.4
junit:1259.v65ffcef24a_88
kubernetes:4186.v1d804571d5d4
kubernetes-client-api:6.10.0-240.v57880ce8b_0b_2
kubernetes-credentials:0.11
lockable-resources:1232.v512d6c434eb_d
mailer:463.vedf8358e006b_
manage-permission:1.0.1
matrix-auth:3.2.1
matrix-project:822.824.v14451b_c0fd42
metrics:4.2.21-449.v6960d7c54c69
mina-sshd-api-common:2.12.0-90.v9f7fb_9fa_3d3b_
mina-sshd-api-core:2.12.0-90.v9f7fb_9fa_3d3b_
nodejs:1.6.1
oauth-credentials:0.646.v02b_66dc03d2e
okhttp-api:4.11.0-172.vda_da_1feeb_c6e
parameterized-scheduler:255.v73827fcdf618
pipeline-build-step:540.vb_e8849e1a_b_d8
pipeline-graph-analysis:202.va_d268e64deb_3
pipeline-graph-view:223.vf9249decdfcd
pipeline-groovy-lib:704.vc58b_8890a_384
pipeline-input-step:491.vb_07d21da_1a_fb_
pipeline-maven:1376.v18876d10ce9c
pipeline-maven-api:1376.v18876d10ce9c
pipeline-maven-database:1376.v18876d10ce9c
pipeline-milestone-step:111.v449306f708b_7
pipeline-model-api:2.2175.v76a_fff0a_2618
pipeline-model-definition:2.2175.v76a_fff0a_2618
pipeline-model-extensions:2.2175.v76a_fff0a_2618
pipeline-npm:204.v4dc4c2202625
pipeline-rest-api:2.34
pipeline-stage-step:305.ve96d0205c1c6
pipeline-stage-tags-metadata:2.2175.v76a_fff0a_2618
pipeline-stage-view:2.34
pipeline-utility-steps:2.16.1
plain-credentials:143.v1b_df8b_d3b_e48
plugin-util-api:3.8.0
popper-api:1.16.1-3
popper2-api:2.11.6-4
prism-api:1.29.0-10
pubsub-light:1.18
release:1.1.4
resource-disposer:0.23
rest-list-parameter:1.7.0
scm-api:683.vb_16722fb_b_80b_
script-security:1321.va_73c0795b_923
select2-api:4.0.13-8
simple-theme-plugin:176.v39740c03a_a_f5
skip-notifications-trait:313.vd1337c8f8134
snakeyaml-api:2.2-111.vc6598e30cc65
soapui-pro-functional-testing-fednot:1.13
sonar:2.17.1
sse-gateway:1.26
ssh-agent:346.vda_a_c4f2c8e50
ssh-credentials:308.ve4497b_ccd8f4
sshd:3.322.v159e91f6a_550
structs:337.v1b_04ea_4df7c8
templating-engine:2.5.3
thinBackup:1.18
token-macro:400.v35420b_922dcb_
trilead-api:2.133.vfb_8a_7b_9c5dd1
uno-choice:2.8.1
variant:60.v7290fc0eb_b_cd
warnings-ng:10.7.0
workflow-aggregator:596.v8c21c963d92d
workflow-api:1291.v51fd2a_625da_7
workflow-basic-steps:1042.ve7b_140c4a_e0c
workflow-cps:3853.vb_a_490d892963
workflow-cps-global-lib:612.v55f2f80781ef
workflow-durable-task-step:1327.ve57634fb_09ce
workflow-job:1400.v7fd111b_ec82f
workflow-multibranch:773.vc4fe1378f1d5
workflow-scm-step:415.v434365564324
workflow-step-api:657.v03b_e8115821b_
workflow-support:865.v43e78cc44e0d
ws-cleanup:0.45

What Operating System are you using (both controller, and any agents involved in the problem)?

Rocky Linux 8.10 with Docker

Reproduction steps

  1. Create a Pull Request in Bitbucket (or reuse an existing PR)
  2. Checkout the Pull Request's branch and create a new branch on top of it
  3. Without adding any extra commits, push the branch to remote

Expected Results

No extra builds should be visible (blocking) on the existing PR in Bitbucket.

Actual Results

An extra build appears on the PR based on the build of the other branch. On top of that, if the branch is then deleted while the build is ongoing, the build status in Bitbucket remains blocked on "In Progress" and we cannot merge the PR.

Anything else?

I have also noticed that the POST operation used by the plugin here has been officially deprecated: https://developer.atlassian.com/server/bitbucket/rest/v900/api-group-deprecated/#api-build-status-latest-commits-commitid-post

Maybe the way the key property is retrieved here is wrong ?

Are you interested in contributing a fix?

No response

@jroch jroch added the bug label Sep 2, 2024
@jroch jroch changed the title Incorrect build notification status sent when 2 branches point to the same commit Build status linked to unrelated Pull Request when 2 branches point to the same commit Sep 2, 2024
@KalleOlaviNiemitalo
Copy link
Contributor

I understand from jenkinsci/atlassian-bitbucket-server-integration-plugin#401 (comment) that, if you used the newer build status API and provided the optional ref parameter, then Bitbucket Server would hide the build status from pull requests that don't involve the specified ref.

#621 and #778 request using the newer build status API.

@KalleOlaviNiemitalo
Copy link
Contributor

On top of that, if the branch is then deleted while the build is ongoing, the build status in Bitbucket remains blocked on "In Progress" and we cannot merge the PR.

That would have to be fixed separately. It does not depend on which build-status REST API is used. IIRC the problem is that, when the branch is deleted, Jenkins switches the job to NullSCM, and then this plugin will no longer know where it should send the build status when the build finishes. It could be fixed by making this plugin save that information when it sends the build-in-progress status.

@mguillem
Copy link

mguillem commented Sep 3, 2024

As far as I know Bitbucket associates the build status information to the commit id. For one or two years I had opened a Bitbucket issue for that but sadly it wasn't seen as a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants