I am trying to create new issue using rest api with cURL command using cronjob

Charan Nagaraja September 27, 2019

I am trying to create issue using REST API with curl command which is 

 

curl -d "@issue.json" -H "Content-Type: application/json" -X POST -u username:password https://jirasd.mycompany.com/rest/api/2/issue/ | python3 -m json.tool

Curl commands executes successfully and the new issue creates in project but when i am trying to execute cronjob for every minute with this command is not working as expected i tried below workflows 

$ crontab -e

$ * * * * * curl -d "@issue.json" -H "Content-Type: application/json" -X POST -u username:password https://jirasd.mycompany.com/rest/api/2/issue/ | python3 -m json.tool

After saving no response at all. Please guide me if i am giving wrong formats in crontab?

I even tried commading like 

* * * * * /home/desktop/test.sh still not working 

* * * * * /home/desktop/test.sh >> /tmp/test.json   It throws me an error of {"errorMessages":["No content to map to Object due to end of input"]}

Please help me to fix this issue.

Regards,

CN

1 answer

0 votes
Andrew Laden
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2019

Not necessarily specific to jira but more to cron usage. (and forgive me if i am going over things you may already know)

Cron will not run in the same user environment as an interactive shell. Check to see if there are things you are assuming (paths, etc) that may not be true when run from cron. Assume nothing. (like the path to your data file)

If you use selinux, check that it is not getting in the way. Temporarily set to "permissive" and see if it works. (you dont want to know how many hours I have spent debugging a problem only to realize that selinux was blocking me.)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events