Coder Social home page Coder Social logo

Comments (17)

jglick avatar jglick commented on June 16, 2024 3

Steps cannot take closures with arguments. (Even if they could, such a syntax would be incompatible with Declarative Pipeline.) You can add either an environment variable or a custom contextual object that other steps can look for:

withCheck('My Check Name') {
    sh 'test --output output.xml'
    junit 'output.xml'
}

from checks-api-plugin.

jglick avatar jglick commented on June 16, 2024 1

update an existing check

There is no need for a special API. You just submit a check with the same name and different details.

from checks-api-plugin.

timja avatar timja commented on June 16, 2024 1

the suggestion is that adding a new object that contains checks context information would allow other implementations to resolve the name from that object rather than using a default.

i.e.:

withChecks('my junit') {
  // this adds a ChecksInfo or something which has a name
  junit '*.xml'
}

and junit would report 'my junit'

which woud mean there would be a standard way to provide a checks name (although a default would still be required)

and yes ah Bill mentioned it would allow publishing the in progress check as well

from checks-api-plugin.

jglick avatar jglick commented on June 16, 2024 1

Or if for architectural reasons it is impossible for Jenkins to keep track of this information (the earlier check was posted by a different plugin, for example), github-checks could at your option track the start time of a given build × check name in some InvisibleAction so that an update could be displayed as occupying an interval of time.

from checks-api-plugin.

mrginglymus avatar mrginglymus commented on June 16, 2024 1

I've opened a PR against github-api to allow for updates: hub4j/github-api#980 - it appears to be a very small change required to get it to work.

from checks-api-plugin.

mrginglymus avatar mrginglymus commented on June 16, 2024 1

This was fixed by #49

from checks-api-plugin.

XiongKezhi avatar XiongKezhi commented on June 16, 2024

would it make sense if I expose the status instead of setting it as completed (we can use that as default if the user didn't provide the status)?

Since we don't have the mechanism to track the status of a check unless we request GitHub through project name, PR, and check name which is bad IMO.

from checks-api-plugin.

mrginglymus avatar mrginglymus commented on June 16, 2024

Ah yes, sorry - spent too much time on shared libraries - where what I've written is roughly what I implemented before I realised it woudln't really work without more plugin support.

A contextual checks object would make a lot of things easier.

from checks-api-plugin.

jglick avatar jglick commented on June 16, 2024

If interested, check Javadoc.

from checks-api-plugin.

mrginglymus avatar mrginglymus commented on June 16, 2024

Since we don't have the mechanism to track the status of a check unless we request GitHub through project name, PR, and check name which is bad IMO.

Yes, that wouldn't be ideal! Can we not add the id returned by the checks provider to the ChecksDetails? It doesn't seem an unreasonable assumption that any checks provider would provide a unique id to allow updating the check. I see that github-api is lacking an api to update an existing check, beyond the internal implementation of paginating annotations. That looks like it should at least be a fairly simple addition to make.

from checks-api-plugin.

mrginglymus avatar mrginglymus commented on June 16, 2024

Ah, does that work? I tried to find details of what happens in the github docs and it wasn't clear. I note that github-api does explicitly call the update endpoint to append annotations.

from checks-api-plugin.

XiongKezhi avatar XiongKezhi commented on June 16, 2024

Ah, does that work? I tried to find details of what happens in the github docs and it wasn't clear. I note that github-api does explicitly call the update endpoint to append annotations.

That's how our status checks work.

from checks-api-plugin.

mrginglymus avatar mrginglymus commented on June 16, 2024

I believe you, I just wish the documentation was a bit clearer :) For instance I wonder what it does to existing annotations?

from checks-api-plugin.

XiongKezhi avatar XiongKezhi commented on June 16, 2024

After reading so many conversations about the custom names for JUnit checks, I'm still a little confused at some points.

You create this issue here just want us to provide the ability to update the checks, which you can actually do by publishing checks with the same name as long as you call the publishChecks in the same branch. Does that meet your needs? Or you need more to publish different status to help you keep track of your builds, since now publishChecks will only publish completed checks?

And about the withChecks step, you write the closure because you tend to use it to let it help you create or update the checks published by others plugins? I currently have no idea how to implement it (I'm not quite familiar with the interactions between the pipeline code and java code), since in my understanding, shouldn't such works are achieved by shared libraries?

from checks-api-plugin.

mrginglymus avatar mrginglymus commented on June 16, 2024

So I did initially try just creating a checks with the same name, however, this didn't work as I would hope as, because every time time the checks api posts a new check to github it clobbers the started at time:

https://github.com/jenkinsci/github-checks-plugin/blob/26c5abfa13b47289f28df94583dabf33901eb6ce/src/main/java/io/jenkins/plugins/checks/github/GitHubChecksPublisher.java#L88

For almost every other field this doesn't matter, as it's the last value that matters (title, status, details, finished at etc etc) but for started at the only thing that knows it is the first check I post. The junit plugin (currently) has no way of knowing what time the check was started, and unless I'm missing something undocumented in the github docs, when we post a new check it entirely replaces the old check.

from checks-api-plugin.

jglick avatar jglick commented on June 16, 2024

it clobbers the started at time

Well, not sure if the junit plugin even defines otherwise (by default a check would be considered instantaneous), but if so, then it should keep track of the time when the check was first added under a given name, and use that same explicit start time.

from checks-api-plugin.

XiongKezhi avatar XiongKezhi commented on June 16, 2024

I'm figuring out a way to update the checks.

We need an update method:

public void update(ChecksDetails addedDetails);

or

public void update(CheckDetails originDetails, ChecksDetails addedDetails);

since the dependent github-api library doesn't support updating the checks either (which always POST instead PATCH as github documented for updating a check), we just append things (started at time, annotations) in addedDetails to originDetails and publish another again.

And another problem is, where we define this method, in checks-api, github-check, or just in the withChecks step?

@timja @jglick

from checks-api-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.