checks-api-plugin icon indicating copy to clipboard operation
checks-api-plugin copied to clipboard

publishChecks Fails Silently When Unable to Infer Repository or Commit Details

Open nadendlaprasad opened this issue 10 months ago • 2 comments

Issue summary

I had to switch back to githubNotify because publishChecks was unable to infer the repository or commit hash details. Additionally, there is no way to explicitly pass these details. There are no logs indicating whether it is skipping the operation or failing, making it difficult to debug.

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

Jenkins 2.499 Checks API plugin Version 367.v18b_7f530e54a_ GitHub Checks plugin Version 602.v264a_83610da_6

Reproduction steps

Using scripted pipeline, here the step for checkout

checkout([$class: 'GitSCM',
            branches: [[name: "master}"]],
            doGenerateSubmoduleConfigurations: false,
            extensions: [[
                $class: 'CloneOption',
                noTags: true,
                reference: '',
                shallow: true,
                depth: 1
            ]
            ,[$class: 'SparseCheckoutPaths',  sparseCheckoutPaths:[[$class:'SparseCheckoutPath', path:"${path}"]]]],
            submoduleCfg: [],
            userRemoteConfigs: [[credentialsId: "<credentialId>",
            url: "<repository url>"]]])

Publishing check

publishChecks name: 'test', status: 'IN_PROGRESS',title: 'testing',summary: 'Running', conclusion : 'NONE'

Expected Results

publishChecks should either infer the necessary details or provide a way to specify them manually. If it cannot determine the required details, it should log a clear error or warning instead of failing silently.

Actual Results

The function does not execute as expected, but no errors or logs provide insight into what went wrong. Would appreciate any guidance on how to resolve this or if there's an alternative approach.

Anything else?

No response

Are you interested in contributing a fix?

yes

nadendlaprasad avatar Mar 13 '25 11:03 nadendlaprasad

Warning if unable to infer

It should be doable by making PublishChecksStepExecution.run() detect whether ChecksPublisherFactory.fromRun returned an instance of NullChecksPublisher.

Specifying the repository and commit in Jenkinsfile

The repository and commit details are currently inferred by ChecksPublisherFactory implementations in other plugins (such as github-checks-plugin and gitea-checks-plugin), not by checks-api-plugin itself. So if Jenkinsfile should be able to specify those details explicitly, then that will need changes in multiple plugins: first checks-api-plugin must pass the information through, and then the other plugins must use it.

I feel the explicit repository and commit info would be better passed to the withChecks step than to the publishChecks step, because the data from withChecks could then affect the recordIssues, junit, and xunit steps as well, without needing specific implementation in those steps. The ChecksPublisherFactory implementations would still have to be changed, though.

I don't know what is the specific data that should be passed to ChecksPublisherFactory. An SCMRevision instance perhaps? That way, the API would not be specific to Git.

Tangent on StepContext

I'd like ChecksPublisherFactory implementations to be able to call StepContext.get(Class) so that they can look up context information specific to the forge service, beyond what checks-api-plugin itself supports. For example, if a forge named Example supports an icon URL for a checks run even though class ChecksDetails doesn't, then example-checks-plugin could define a withExampleChecks step that adds the icon URL to StepContext, and a Jenkinsfile could then use withExampleChecks(iconUrl: ...) { ... } around publishChecks steps.

KalleOlaviNiemitalo avatar Mar 13 '25 13:03 KalleOlaviNiemitalo

What type of credential is your credentialsId ?

timja avatar Mar 17 '25 15:03 timja