# Discover comment.id

**URL:** https://community.jenkins.io/t/discover-comment-id/35666
**Category:** Ask a question
**Created:** [September 29, 2025, 8:44pm UTC](https://community.jenkins.io/t/discover-comment-id/35666 "2025-09-29T20:44:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sdarwin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/sdarwin/32/10231_2.png) [@sdarwin](https://community.jenkins.io/u/sdarwin)
#### Post date: [September 29, 2025, 8:44pm UTC](https://community.jenkins.io/t/discover-comment-id/35666/1 "2025-09-29T20:44:38Z")

</div>

Using the pipeline-github-plugin in a Jenkins pipeline.

> **[GitHub - jenkinsci/pipeline-github-plugin: Pipeline: GitHub](https://github.com/jenkinsci/pipeline-github-plugin/)**
>
> Pipeline: GitHub

You can post a comment to github: pullRequest.comment(commenttext)

To edit the comment later, you’d need to know “comment.id”.

There does seem to be an obscure return value from pullRequest.comment() but it’s not the comment.id. Any idea how to retrieve the id?

Thanks.

---

<div class="post-metadata">

### Author: ![sdarwin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/sdarwin/32/10231_2.png) [@sdarwin](https://community.jenkins.io/u/sdarwin)
#### Post date: [September 30, 2025, 12:05am UTC](https://community.jenkins.io/t/discover-comment-id/35666/2 "2025-09-30T00:05:14Z")

</div>

COMMENT\_ID=$(curl -L -H “Accept: application/vnd.github+json” -H “X-GitHub-Api-Version: 2022-11-28” [https://api.github.com/repos/$ORGANIZATION/$REPONAME/issues/${CHANGE\_ID}/comments](https://api.github.com/repos/$ORGANIZATION/$REPONAME/issues/$%7BCHANGE_ID%7D/comments) | jq ‘. | select(.body|test(“Some text to recognize”)) | .id’ | tail -n 1)

---

<div class="post-metadata">

### Author: ![sdarwin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/sdarwin/32/10231_2.png) [@sdarwin](https://community.jenkins.io/u/sdarwin)
#### Post date: [October 1, 2025, 9:02pm UTC](https://community.jenkins.io/t/discover-comment-id/35666/3 "2025-10-01T21:02:11Z")

</div>

Experiment 1:

The earlier curl method is interesting and does work.

Next:

The README example contains the answer, hiding in plain sight. (Sometimes that’s easy to miss.) Literally “comment.id”.

### **Adding a comment**

```auto
def comment = pullRequest.comment('This PR is highly illogical..')

```

### **Editing a comment**

```auto
pullRequest.editComment(comment.id, 'Live long and prosper.')
// or
comment.body = 'Live long and prosper.'

```
