Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to comment the Job Stage via Rest API

Dileep Kumar Mone April 6, 2021

Hi All,

I am trying to comment on the issue via the Rest API. That comment should add the content related to the CI Job Info from GitLab. But if I am trying as a string it's working fine. But if I am trying to comment via the ${CI_JOB_STAGE} but its just printing the same. And also if I am trying the echo I can see the result of the Job Stage as expected but the comment is not printing correctly. Please find the below shell script which I have worked.

curl -D- -u xxxxxx:xxxxx -X POST --data '{"body": "$CI_JOB_NAME"}' -H "Content-Type: application/json" https://xxxxxxx.atlassian.net/rest/api/2/issue/xx-6/comment

Kindly help us how can I acheive this

1 answer

0 votes
Thomas Deiler
Community Champion
April 10, 2021

Dear @Dileep Kumar Mone ,

the CI_JOB_STAGE seems to be a variable of your CI. Jira cannot resolve it. Make sure your CI uses the right variables. For testing you could replace the CURL command with

echo "${CI_JOB_STAGE}" > /path/to/file/test_comment.txt

and see if there is something written into.

So long

Thomas

Thomas Deiler
Community Champion
May 5, 2021

Dear @Dileep Kumar Mone ,

was my answer useful? Then I would be happy when you click on the "green accept answer" button.

So long
Thomas

Suggest an answer

Log in or Sign up to answer