Skip to content

Plugin publishes check to previous builds commit when revision is not found for Freestyle jobs #460

@cainan-winquist

Description

@cainan-winquist
Jenkins and plugins versions report

Jenkins: 2.513
OS: Linux - 6.1.79-99.164.amzn2023.x86_64
Java: 21.0.7 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)

Parameterized-Remote-Trigger:3.2.1
ansicolor:1.0.6
antisamy-markup-formatter:173.v680e3a_b_69ff3
apache-httpcomponents-client-4-api:4.5.14-269.vfa_2321039a_83
apache-httpcomponents-client-5-api:5.5-150.veb_76e719855b_
asm-api:9.7.1-97.v4cc844130d97
aws-credentials:248.v78a_dcfc9db_ff
aws-java-sdk-ec2:1.12.772-477.v650d756dcf6d
aws-java-sdk-minimal:1.12.772-477.v650d756dcf6d
aws-java-sdk-secretsmanager:1.12.529-406.vdeff15e5817d
aws-java-sdk2-core:2.31.45-50.vee50cf9f54c3
aws-java-sdk2-ec2:2.31.45-50.vee50cf9f54c3
aws-secrets-manager-credentials-provider:1.214.va_0a_d8268d068
bootstrap5-api:5.3.3-2
bouncycastle-api:2.30.1.80-261.v00c0e2618ec3
branch-api:2.1217.v43d8b_b_d8b_2c7
build-name-setter:2.5.0
build-timeout:1.38
build-user-vars-plugin:176.vb_9c7907fd524
build-with-parameters:76.v9382db_f78962
caffeine-api:3.2.0-166.v72a_6d74b_870f
checks-api:373.vfe7645102093
cloudbees-folder:6.1023.v4fcb_72152519
command-launcher:123.v37cfdc92ef67
commons-lang3-api:3.17.0-87.v5cf526e63b_8b_
commons-text-api:1.13.1-176.v74d88f22034b_
configuration-as-code:1971.vf9280461ea_89
configuration-as-code-groovy:1.1
coverage:2.7.0
credentials:1415.v831096eb_5534
credentials-binding:687.v619cb_15e923f
customizable-header:214.vf2a_c8767e457
dark-theme:567.v9d3ca_a_3142f5
data-tables-api:2.2.2-1
display-url-api:2.209.v582ed814ff2f
durable-task:577.v2a_8a_4b_7c0247
ec2:1935.v9b_77210472b_1
echarts-api:5.6.0-4
eddsa-api:0.3.0.1-19.vc432d923e5ee
email-ext:1911.v19b_8e86f9815
envinject:2.926.v69c9b_3896a_96
envinject-api:1.235.va_14c74f8f487
extended-read-permission:61.vf24570ff3b_e9
flatpickr-api:4.6.13-18.vcf5f6a_5b_8468
font-awesome-api:6.7.2-1
forensics-api:3.1.0
generic-webhook-trigger:2.3.1
git:5.7.0
git-client:6.1.0
github:1.43.0
github-api:1.321-478.vc9ce627ce001
github-branch-source:1822.v9eec8e5e69e3
github-checks:602.v264a_83610da_6
github-oauth:651.v135e939e8b_60
gson-api:2.11.0-109.v1ef91dd0829a_
instance-identity:203.v15e81a_1b_7a_38
ionicons-api:88.va_4187cb_eddf1
jackson2-api:2.18.3-402.v74c4eb_f122b_2
jakarta-activation-api:2.1.3-2
jakarta-mail-api:2.1.3-2
javax-activation-api:1.2.0-7
javax-mail-api:1.6.2-11
jaxb:2.3.9-133.vb_ec76a_73f706
jdk-tool:83.v417146707a_3d
jjwt-api:0.11.5-112.ve82dfb_224b_a_d
job-dsl:1.93
jobConfigHistory:1330.vcb_8320ea_cdb_e
joda-time-api:2.14.0-127.v7d9da_295a_d51
jquery3-api:3.7.1-3
json-api:20250107-125.v28b_a_ffa_eb_f01
json-path-api:2.9.0-148.v22a_7ffe323ce
jsoup:1.21.1-52.v96e4041b_60fd
junit:1335.v6b_a_a_e18534e1
lockable-resources:1349.v8b_ccb_c5487f7
mailer:489.vd4b_25144138f
mask-passwords:199.va_0218b_a_59186
matrix-auth:3.2.6
matrix-project:849.v0cd64ed7e531
mina-sshd-api-common:2.14.0-143.v2b_362fc39576
mina-sshd-api-core:2.14.0-143.v2b_362fc39576
mina-sshd-api-scp:2.14.0-143.v2b_362fc39576
node-iterator-api:72.vc90e81737df1
okhttp-api:4.11.0-189.v976fa_d3379d6
opentelemetry:3.1543.v8446b_92b_cd64
opentelemetry-api:1.49.0.59.vc32561e77cf3
parameterized-scheduler:285.ve611986d4c48
parameterized-trigger:859.vb_e3907a_07a_16
pipeline-build-step:571.v08a_fffd4b_0ce
pipeline-graph-analysis:241.vc3d48fb_b_2582
pipeline-groovy-lib:752.vdddedf804e72
pipeline-input-step:513.v7eb_fe7e2c0fc
pipeline-model-api:2.2255.v56a_15e805f12
pipeline-model-definition:2.2255.v56a_15e805f12
pipeline-model-extensions:2.2255.v56a_15e805f12
pipeline-stage-step:322.vecffa_99f371c
pipeline-stage-tags-metadata:2.2255.v56a_15e805f12
plain-credentials:195.vb_906e9073dee
plugin-util-api:6.1.0
postbuildscript:3.4.1-695.vf6b_0b_8053979
prism-api:1.30.0-1
rebuild:338.va_0a_b_50e29397
resource-disposer:0.24
saml:4.544.v264eea_ed3eed
scm-api:704.v3ce5c542825a_
script-security:1373.vb_b_4a_a_c26fa_00
sidebar-link:2.4.2
slack:761.v2a_8770f0d169
snakeyaml-api:2.3-125.v4d77857a_b_402
ssh-agent:386.v36cc0c7582f0
ssh-credentials:355.v9b_e5b_cde5003
ssh-slaves:3.1031.v72c6b_883b_869
sshd:3.353.v2b_d33c46e970
structs:350.v3b_30f09f2363
theme-manager:294.vf2c2fd783821
throttle-concurrents:2.16
timestamper:1.29
token-macro:444.v52de7e9c573d
trilead-api:2.147.vb_73cc728a_32e
variant:60.v7290fc0eb_b_cd
workflow-api:1373.v7b_813f10efa_b_
workflow-basic-steps:1079.vce64b_a_929c5a_
workflow-cps:4106.v7a_8a_8176d450
workflow-durable-task-step:1405.v1fcd4a_d00096
workflow-job:1537.v66038d35fc76
workflow-multibranch:806.vb_b_688f609ee9
workflow-scm-step:437.v05a_f66b_e5ef8
workflow-step-api:700.v6e45cb_a_5a_a_21
workflow-support:968.v8f17397e87b_8
ws-cleanup:0.48

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

Linux - 6.1.49-70.116.amzn2023.x86_64

Reproduction steps

Create a Freestyle Jenkins job that uses Git Source code management with the Github App and Github checks enabled. Run first on a commit of an existing Github pull request. The check status should be successful:

`

git rev-parse --resolve-git-dir /home/ec2-user/workspace/freestyle-test/.git # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url https://github.com/test/plugin-test # timeout=10
Cleaning workspace
git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
git clean -fdx # timeout=10
Using shallow fetch with depth 10
Fetching upstream changes from https://github.com/test/plugin-test
git --version # timeout=10
git --version # 'git version 2.47.1'
using GIT_ASKPASS to set credentials Github app to set check status using https://plugins.jenkins.io/github-checks/
git fetch --no-tags --force --progress --depth=10 -- https://github.com/test/plugin-test +refs/pull/55/:refs/remotes/origin/pr/55/ # timeout=10
git rev-parse a3b3b8cfe0fd05dd9d178a3f27a4882c35a257ad^{commit} # timeout=10
Checking out Revision a3b3b8cfe0fd05dd9d178a3f27a4882c35a257ad (detached)
git config core.sparsecheckout # timeout=10
git checkout -f a3b3b8cfe0fd05dd9d178a3f27a4882c35a257ad # timeout=10
Commit message: "Update README.md"
git rev-list --no-walk 8e4d935d8cc79e738838d1a5d235c3be8d2eb17a # timeout=10
[GitHub Checks] GitHub check (name: Jenkins, status: in_progress) has been published.
[freestyle-test] $ /bin/sh -xe /tmp/jenkins14686630651419590546.sh
echo test
test
[GitHub Checks] GitHub check (name: Jenkins, status: completed) has been published.
Finished: SUCCESS`

Then, change the commit to an invalid value (Ex: "1234") that would be run by a different PR. The checkout will fail, and the status will be reported to the last successful build (above), and the status will be changed to fail:

`

git rev-parse --resolve-git-dir /home/ec2-user/workspace/freestyle-test/.git # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url https://github.com/test/plugin-test # timeout=10
Cleaning workspace
git rev-parse --verify HEAD # timeout=10
Resetting working tree
git reset --hard # timeout=10
git clean -fdx # timeout=10
Using shallow fetch with depth 10
Fetching upstream changes from https://github.com/test/plugin-test
git --version # timeout=10
git --version # 'git version 2.47.1'
using GIT_ASKPASS to set credentials Github app to set check status using https://plugins.jenkins.io/github-checks/
git fetch --no-tags --force --progress --depth=10 -- https://github.com/test/plugin-test +refs/pull/56/:refs/remotes/origin/pr/56/ # timeout=10
git rev-parse 1234123412341234^{commit} # timeout=10
git rev-parse origin/1234123412341234^{commit} # timeout=10
git rev-parse 1234123412341234^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
[GitHub Checks] GitHub check (name: Jenkins, status: completed) has been published.
Finished: FAILURE`

Expected Results

Status checks should report to the correct commit that it was trigger from.

Actual Results

Status checks of a failing build are reported to the previous build, which is unrelated.

Anything else?

This breaks our workflow, since when this occurs it will randomly fail someone elses build that triggers it.

I'm guessing it comes from some of the logic here where we try and pull the last build revision information, which can be a completely different Jenkins runs.

Are you interested in contributing a fix?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions