Product Management,  Programming

Create Jira Issues From The Command Line

You can use the command line to create Jira tickets. In the below one-liner, we’re going to bring in some standard json and create a ticket. We’ll use curl and use -u to define a username and password, then -X to define a POST and –data to define the contents of the post, wrapped in the single quotes below. Then -H defines the content type as json and a URL to your Jira rest endpoint, “Issues” in the below code:

curl -D- -u krypted:MySuperSecretPassword -X POST --data '{"fields":{"project":{"key": “DOG”},”summary": “Make my feature better.”,”description": “Going to make everything better ever ever ever by doing things and by things I mean allll the things“,”customfield_001”:”Testing testing”,”issuetype": {"name": “Story”}{“time tracking”:{originalEstimate”: “2d 4h”}}}’ -H "Content-Type: application/json" https://krypted.atlassian.net/rest/api/2/issue/

You can swap out the json here with input to a script, or a file. That json can look prettier than it looks in the above single line:

{
 "fields":{
   "project":
   {
    "key": “DOG”
   },
   ”summary": “Make my feature better.”,
   ”description": “Going to make everything better ever ever ever by doing things and by things I mean allll the things“,
   ”customfield_001”:”Testing testing”,
   ”issuetype": {
    "name": “Story”
   }
   {
    “time tracking”:{
    originalEstimate”: “2d 4h”
   }
  }
}

As you can see, we’re creating an issue in the DOG project (which could also say CAT or whatever was generated when you created the project you’re putting this issue into). We’re then adding a “summary” and “description” as I don’t think you can really create one without that information. Then we’re adding information for a custom field our organization created and finally an estimate for how long the task should take, with those being very much optional.

So any other fields you have available can also be created as well, just add them to the correct part of the json with the correct label and inputs to accept.