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

[Question] Hanging checks with "withChecks()" #199

Closed
noru opened this issue Nov 4, 2022 · 5 comments
Closed

[Question] Hanging checks with "withChecks()" #199

noru opened this issue Nov 4, 2022 · 5 comments

Comments

@noru
Copy link

noru commented Nov 4, 2022

Hi,

I'm using Checks API plugin along with Github Checks API. According to the document, I wrote this code in my pipeline script:

steps {
    withChecks('CI/Main/CheckStyle') {
        // do stuff
        exit 1 // if error occured, the check will be completed with error  
         
        // But if everything is fine, no "COMPLETED" is published to the check, leave it forever hanging.
        // to solve this I'll have to manually do a publish 
        echo 'hello'
        publishChecks(name: 'CI/Main/CheckStyle', conclusion: 'SUCCESS', summary: 'Lint passed')
    }
}

The check is successfully published, but, as described above, I'll have to manually complete a check in my steps.

It seems the code didn't publish any checks in onSuccess on purpose.

I googled a lot for the usage of withChecks, no mention of this behavior. And examples on Github simply wrap normal steps without the manual complete.

I'm new to this, my usage could be wrong. Could someone help me with the correct usage of witchChecks? Appreciated!

@KalleOlaviNiemitalo
Copy link

That was discussed in #49 (comment).

@noru
Copy link
Author

noru commented Nov 4, 2022

Thanks @KalleOlaviNiemitalo ! That explains it.

Though this should be documented properly I think.

@noru noru closed this as completed Nov 4, 2022
@mrginglymus
Copy link
Contributor

The pattern I'd always intended to use with this (but never got round to implementing) was to add an optional checks publisher to warnError. For e.g. running tests you can do:

withChecks('My Tests') {
    sh 'run_tests > results.xml'
    junit 'results.xml'
}

and that works fine; sometimes you have a one-shot command where you just want to report success or failure. It would be nice to extend warnError to be checks aware:

withChecks('One Shot') {
    warnError('One Shot') {
        sh 'one_shot'
    }
}

ie, have warnError report the appropriate success/failure message to the active checks context.

Alternatively get warnError to be fully responsible for doing the checks itself, so

warnError(message: 'One Shot', publishChecks: true) {
    sh 'one_shot'
}

Not sure why I never got round to doing it, but happy to take another look if people think it might be a useful pattern?

@timja
Copy link
Member

timja commented Nov 4, 2022

created #200 to track enhancement

@timja
Copy link
Member

timja commented Apr 3, 2024

Semi related pull request which helps in some cases: #254

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