I have a CI job that computes some information based on previous jobs (comparison of artifact sizes). It’s not something I could gate the whole pipeline on, because it’s more nuanced that just pass/fail. So my thought was to do something similar to what Codecov or other services do, and render a report to post as a comment on the MR that triggered the pipeline. This is possible via the “notes” API.
The problem is, I don’t want to have dozens of such comments dumped in the MR. I want to do what Codecov does, where they post a comment and then just update it when the pipeline runs again.
I can’t figure out a “lightweight” way to do this though. I assume that Codecov achieves this by storing the note ID in their infrastructure and using the modify/PUT method when the comment already exists. But I am not running a whole other service, I’m just trying to write a simple, self-contained CI job.
The only other approach I can think of is to add some very specific content to the comment that I can detect on subsequent runs ie. I use the list API to list all the comments, parse each one for the marker content, and update that one. That seems a bit fragile though, because there’s pagination to consider, and it just seems a bit overcomplicated and wasteful. (I’m leaving aside the fact that the special comment could be edited to remove the marker content, or the marker could be added to an ordinary comment, because someone would have to do that on purpose, and the worst that happens is duplication or removal of a comment. But it’s also possible.)
My basic questions are:
- Is there a way to store the comment ID for future runs of a pipeline, scoped to a given MR?
- Is there another approach to this that I haven’t thought of?