Plugin sends results to previous repository
Context
Team does PR-linting as a service. Users should be able to just install a GitHub app and ask for their repository to be added to a list of repositories our team lints.
Version report
Jenkins and plugins versions report:
Jenkins: 2.289.2
OS: Linux - RHEL7
---
ace-editor:1.1
active-directory:2.24
analysis-model-api:10.2.5
ansicolor:1.0.0
ant:1.11
antisamy-markup-formatter:2.1
apache-httpcomponents-client-4-api:4.5.13-1.0
authentication-tokens:1.3
authorize-project:1.4.0
blueocean:1.24.8
blueocean-autofavorite:1.2.4
blueocean-bitbucket-pipeline:1.24.8
blueocean-commons:1.24.8
blueocean-config:1.24.8
blueocean-core-js:1.24.8
blueocean-dashboard:1.24.8
blueocean-display-url:2.4.1
blueocean-events:1.24.8
blueocean-git-pipeline:1.24.8
blueocean-github-pipeline:1.24.8
blueocean-i18n:1.24.8
blueocean-jwt:1.24.8
blueocean-personalization:1.24.8
blueocean-pipeline-api-impl:1.24.8
blueocean-pipeline-editor:1.24.8
blueocean-pipeline-scm-api:1.24.8
blueocean-rest:1.24.8
blueocean-rest-impl:1.24.8
blueocean-web:1.24.8
bootstrap4-api:4.6.0-1
bootstrap5-api:5.0.2-1
bouncycastle-api:2.21
branch-api:2.6.5
build-timeout:1.20
caffeine-api:2.9.1-23.v51c4e2c879c8
checks-api:1.7.2
cloudbees-bitbucket-branch-source:2.4.4
cloudbees-folder:6.15
command-launcher:1.6
configuration-as-code:1.51
credentials:2.5
credentials-binding:1.27
dark-theme:0.0.12
data-tables-api:1.10.25-2
display-url-api:2.3.5
durable-task:1.38
echarts-api:5.1.2-3
email-ext:2.83
envinject:2.4.0
envinject-api:1.6
favorite:2.3.1
font-awesome-api:5.15.3-4
forensics-api:1.2.1
generic-webhook-trigger:1.74
git:4.8.0
git-client:3.8.0
git-server:1.10
github:1.33.1
github-api:1.123
github-branch-source:2.11.1
github-checks:1.0.13
gradle:1.37.1
handlebars:3.0.8
handy-uri-templates-2-api:2.1.6-1.0
htmlpublisher:1.25
jackson2-api:2.12.4
jaxb:2.3.0
jdk-tool:1.5
jenkins-design-language:1.24.8
jjwt-api:0.11.2-5.143e44951c52
job-dsl:1.77
jquery-detached:1.2.1
jquery3-api:3.6.0-2
jsch:0.1.55.2
junit:1.51
ldap:2.7
lockable-resources:2.11
mailer:1.34
mapdb-api:1.0.9.0
matrix-auth:2.6.8
matrix-project:1.19
mercurial:2.0
momentjs:1.1.1
next-executions:1.0.15
okhttp-api:3.14.9
pam-auth:1.6
pipeline-build-step:2.14
pipeline-github-lib:1.0
pipeline-graph-analysis:1.11
pipeline-input-step:2.12
pipeline-milestone-step:1.3.2
pipeline-model-api:1.8.5
pipeline-model-definition:1.8.5
pipeline-model-extensions:1.8.5
pipeline-rest-api:2.19
pipeline-stage-step:2.5
pipeline-stage-tags-metadata:1.8.5
pipeline-stage-view:2.19
plain-credentials:1.7
plugin-util-api:2.4.0
popper-api:1.16.0-7
popper2-api:2.5.4-3
pubsub-light:1.13
resource-disposer:0.16
scm-api:2.6.4
script-security:1.77
snakeyaml-api:1.29.1
sse-gateway:1.24
ssh-credentials:1.19
ssh-slaves:1.32.0
sshd:3.0.4
structs:1.23
subversion:2.14.4
theme-manager:0.6
timestamper:1.13
token-macro:2.15
trilead-api:1.0.13
variant:1.3
warnings-ng:9.4.0
workflow-aggregator:2.6
workflow-api:2.46
workflow-basic-steps:2.23
workflow-cps:2.93
workflow-cps-global-lib:2.21
workflow-durable-task-step:2.39
workflow-job:2.41
workflow-multibranch:2.26
workflow-scm-step:2.13
workflow-step-api:2.24
workflow-support:3.8
ws-cleanup:0.39
- What Operating System are you using (both controller, and any agents involved in the problem)?
Controller: RHEL7.7
No agents
It shouldn't make an impact, but for reference, the controller is inside a container in k8s.
Reproduction steps
- Setup Github App to listen to pull requests, add credentials to Jenkins
- Configure Github App to send PR events to Generic Webhook Trigger
- Add Github App to two different repositories
- Configure Jenkins job to build on Generic Webhook Trigger event
- Open a PR in
repo-1(referred to as PR1). This should trigger the job, which will- Use GH App credentials to clone PR1 content
- run lint tests
- use Github Checks Plugin to return lint test results
- Open a PR in
repo-2(referred to as PR2). This should trigger the job again, which will- Use GH App credentials to clone PR2 content
- run lint tests
- use Github Checks Plugin to return lint test results
Results
Expected result:
Github Checks Plugin returns lint results for PR2 to repo-2
Actual result:
Github Checks Plugin returns lint results for PR2 to repo-1 (and fails, because repo-1 does not have that commit).
The recommended git tool is: NONE
using credential generic-lint-github-app-credentials-repo-2
Cloning the remote Git repository
Cloning repository https://git/org/repo-2.git
> git init /var/jenkins_home/workspace/generic-pull-request-lint-tests/target-repo # timeout=10
Fetching upstream changes from https://git/org/repo-2.git
> git --version # timeout=10
> git --version # 'git version 1.8.3.1'
using GIT_ASKPASS to set credentials Generic linter GH app credentials (org: repo-2)
> git fetch --tags --progress https://git/org/repo-2.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url https://git/org/repo-2.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
> git rev-parse origin/repo-2^{commit} # timeout=10
Checking out Revision 2c6d90904851dcd4fd55d02b9009cc31c34af9e2 (origin/repo-2)
> git config core.sparsecheckout # timeout=10
> git checkout -f 2c6d90904851dcd4fd55d02b9009cc31c34af9e2 # timeout=10
Commit message: "add a bad key/value to bad.yml"
First time build. Skipping changelog.
[GitHub Checks] Failed Publishing GitHub checks: org.kohsuke.github.GHFileNotFoundException: https://git/api/v3/repos/org/repo-1/check-runs {"message":"No commit found for SHA: 2c6d90904851dcd4fd55d02b9009cc31c34af9e2","documentation_url":"https://docs.github.com/enterprise/3.0/rest/reference/checks#create-a-check-run"}
Edit: Suspect there is some caching issues going on here, perhaps with reference build analysis?
Maybe it is related to this TODO comment: https://github.com/jenkinsci/github-checks-plugin/blob/9e2588962c360a17ba4372d8fa541b604843ff5a/src/main/java/io/jenkins/plugins/checks/github/SCMFacade.java#L227-L230
What type of job do you use in Jenkins? Does the job configuration refer to any repository, or does the repository address come solely as a parameter from the Generic Webhook Trigger plugin?
What type of job do you use in Jenkins?
It's a pipeline that refers to a Groovy script in Github. The pipeline describes which Groovy script (another pipeline) to execute to actually run the tests and report issues to GitHub Enterprise.
Does the job configuration refer to any repository, or does the repository address come solely as a parameter from the Generic Webhook Trigger plugin?
Comes solely as a parameter from the Generic Webhook Trigger plugin.
Example stack trace from error:
Jul 26, 2021 4:20:26 PM WARNING io.jenkins.plugins.checks.github.GitHubChecksPublisher publish
Failed Publishing GitHub checks: ChecksDetails{name='Jenkins', detailsURL='null', status=IN_PROGRESS, conclusion=NONE, startedAt=null, completedAt=null, output=null, actions=[]}
java.io.FileNotFoundException: https://git/api/v3/repos/org/repo-1/check-runs
at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$OkHttpURLConnection.getInputStream(ObsoleteUrlFactory.java:490)
at org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$DelegatingHttpsURLConnection.getInputStream(ObsoleteUrlFactory.java:1204)
at org.kohsuke.github.GitHubHttpUrlConnectionClient$HttpURLConnectionResponseInfo.bodyStream(GitHubHttpUrlConnectionClient.java:196)
at org.kohsuke.github.GitHubResponse$ResponseInfo.getBodyAsString(GitHubResponse.java:314)
at org.kohsuke.github.GitHubResponse.parseBody(GitHubResponse.java:92)
at org.kohsuke.github.Requester.lambda$fetch$1(Requester.java:76)
at org.kohsuke.github.GitHubClient.createResponse(GitHubClient.java:455)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:406)
Caused: org.kohsuke.github.GHFileNotFoundException: https://git/api/v3/repos/org/repo-1/check-runs {"message":"No commit found for SHA: 2c6d90904851dcd4fd55d02b9009cc31c34af9e2","documentation_url":"https://docs.github.com/enterprise/3.0/rest/reference/checks#create-a-check-run"}
at org.kohsuke.github.GitHubClient.interpretApiError(GitHubClient.java:486)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:414)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:358)
at org.kohsuke.github.Requester.fetch(Requester.java:76)
at org.kohsuke.github.GHCheckRunBuilder.create(GHCheckRunBuilder.java:153)
at io.jenkins.plugins.checks.github.GitHubChecksPublisher.publish(GitHubChecksPublisher.java:75)
at io.jenkins.plugins.checks.status.BuildStatusChecksPublisher.publish(BuildStatusChecksPublisher.java:63)
at io.jenkins.plugins.checks.status.BuildStatusChecksPublisher.access$000(BuildStatusChecksPublisher.java:42)
at io.jenkins.plugins.checks.status.BuildStatusChecksPublisher$JobCheckoutListener.lambda$onCheckout$0(BuildStatusChecksPublisher.java:174)
at java.base/java.util.Optional.ifPresent(Optional.java:183)
at io.jenkins.plugins.checks.status.BuildStatusChecksPublisher$JobCheckoutListener.onCheckout(BuildStatusChecksPublisher.java:174)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:155)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Same issue in my pipeline. We use checkout switch git repo before publish the checks.
closing - resolved with alternate (internal) solution