jenkinsci / checks-api-plugin

Jenkins plugin that defines an API for Jenkins to publish checks to SCM platforms.
https://plugins.jenkins.io/checks-api/
MIT License
42 stars 28 forks source link

Add includeStage to allow starting check immediately for JUnit #254

Closed timja closed 6 months ago

timja commented 6 months ago

Relates to https://github.com/jenkinsci/checks-api-plugin/issues/199

I can't see a specific issue for it but I think its came up for it.

The specific usecase I have is for Jenkins core. Multi hour testsuite in some cases. I would like the check to be changed to pending as soon as it starts running the maven build, which can be done by wrapping it with:

withChecks(name: 'Tests', includeStage: true) {
  junit '*.xml'
}

You could work around it before by specifying the full checks name in withChecks, e.g. the stage yourself manually but its clunky.

Example checks names:

Ideally you wouldn't even need to specify the name Tests as thats the default in the JUnit plugin but the only workaround I could think of was making the JUnit step a block scoped step, but I figured this was probably useful to other plugins.

Thoughts?

Testing done

TODO Look at any unit or integration tests

Manually tested at https://github.com/timja-org/junit-attachments-test/pull/9

### Submitter checklist
- [ ] Make sure you are opening from a **topic/feature/bugfix branch** (right side) and not your main branch!
- [ ] Ensure that the pull request title represents the desired changelog entry
- [ ] Please describe what you did
- [ ] Link to relevant issues in GitHub or Jira
- [ ] Link to relevant pull requests, esp. upstream and downstream changes
- [ ] Ensure you have provided tests - that demonstrates feature works or fixes the issue
KalleOlaviNiemitalo commented 6 months ago

"Tests / linux-jdk17 / Linux - JDK 17 - Test" looks a bit redundant. Will withChecks('', includeStage: true) omit the final separator and leave only "Tests / linux-jdk17 / Linux - JDK 17"?

KalleOlaviNiemitalo commented 6 months ago

Oh I see, the "Tests" at the start is what was specified in withChecks. So with an empty step name and omitting the separator, it'd be "linux-jdk17 / Linux - JDK 17 - Test"?

timja commented 6 months ago

Oh I see, the "Tests" at the start is what was specified in withChecks. So with an empty step name and omitting the separator, it'd be "linux-jdk17 / Linux - JDK 17 - Test"?

Yeah should be that

timja commented 6 months ago

Thanks for the review 😄