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

publishChecks - how to publish a fail status? #70

Closed
rmathewsbeyond opened this issue Jan 15, 2021 · 5 comments
Closed

publishChecks - how to publish a fail status? #70

rmathewsbeyond opened this issue Jan 15, 2021 · 5 comments

Comments

@rmathewsbeyond
Copy link

rmathewsbeyond commented Jan 15, 2021

Help wanted!

Great plugin, we use this in our pipeline. Is there a way to publish yellow dot (in progress) and red cross (fail) when using publishChecks? Below is the syntax we use, and all checks published have a green tick (screenshot for reference)

Syntax:
publishChecks(name: 'Jenkins/SBXDEPLOY Deploy', title: 'Cleanup - IN-PROGRESS', summary: '', text: '', detailsURL: "${JENKINS_URL}")

image

@agaudreault
Copy link

Take a look at https://ci.jenkins.io/pipeline-syntax/ and select publishChecks in the list to see the available aprameters and their documentation.

You can use the status and conclusion parameters.

publishChecks name: 'Jenkins/SBXDEPLOY Deploy', status: 'IN_PROGRESS', title: 'Cleanup', conclusion: 'NONE'
and
publishChecks name: 'Jenkins/SBXDEPLOY Deploy', status: 'COMPLETED', title: 'Cleanup', conclusion: 'FAILED'

@rmathewsbeyond
Copy link
Author

Thanks for the guidance, I'm fairly new to jenkins and its plugins. Thanks for sharing the pipeline-syntax, a valuable tool indeed.

I've updated the code to include status and summary. This is my observation, not sure if its an issue.

  • publishChecks(name: 'Jenkins/Scratch Build and Deploy', title: 'Authorize - PASS', summary: '', text: '', detailsURL: "${JENKINS_URL}", status:'IN_PROGRESS')
    on GitHub UI, it still shows green tick, even though status = IN_PROGRESS

  • publishChecks(name: 'Jenkins/Scratch Build and Deploy', title: 'Authorize - FAIL', summary: '', text: '', detailsURL: "${JENKINS_URL}", status:'COMPLETED', conclusion: 'FAILURE')
    on GitHub UI, shows the red cross

Thanks for answering my question, I will close this issue as its giving me what I was mainly looking for ie. red cross on fail. yellow dot for in_progress is a good to have.

@KalleOlaviNiemitalo
Copy link

PublishChecksStep seems to use ChecksConclusion.SUCCESS by default. Does it work better if you explicitly specify conclusion: 'NONE', which would be the default in ChecksDetails.ChecksDetailsBuilder? If it does, then perhaps the default should be changed in PublishChecksStep, or perhaps GitHubChecksPublisher should be changed to ignore the conclusion if the status is IN_PROGRESS.

private ChecksStatus status = ChecksStatus.COMPLETED;
private ChecksConclusion conclusion = ChecksConclusion.SUCCESS;

public ChecksDetailsBuilder() {
this.conclusion = ChecksConclusion.NONE;
this.actions = new ArrayList<>();
}

https://github.com/jenkinsci/github-checks-plugin/blob/6ad6d9260e7f3b262965466971ea3e69a4c06e23/src/main/java/io/jenkins/plugins/checks/github/GitHubChecksPublisher.java#L119-L122

https://github.com/hub4j/github-api/blob/cb381dfa06542d9954de1f58915d70fc6e23e1f7/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java#L100-L105

https://docs.github.com/en/rest/reference/checks#create-a-check-run--parameters

@rmathewsbeyond
Copy link
Author

Thanks, explicitly specifying conclusion: 'NONE' did resolve the issue. Thanks again.

@XiongKezhi
Copy link
Contributor

@KalleOlaviNiemitalo thanks very much, the GitHub will automatically set the status to be completed if the conclusion is provided, so maybe I should change the conclusion to NONE when the status is queued or in_progress.

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

No branches or pull requests

4 participants