Posting bulk Jira Issues with JiraJelly and cURL

One thing that Atlassian’s Jira does not allow is the posting of tasks to multiple recipients. So the below is a snippet that shows how to create and post JiraJelly scripts using cURL within PHP.

Note, on the calling page I used ldap_connect to query our AD database for a list of users. A little html and jQuery allowed the user to select the required users from the list, and input the required fields for the Jira task.

I then use some basic PHP to create some XML in the form of:

<JiraJelly xmlns:jira='jelly:com.atlassian.jira.jelly.JiraTagLib'>
    <jira:CreateIssue 
        project-key='<project key>'
        assignee='<assignee>'
        priority='<priority>';
        summary='<summary>'
        reporter='<reporter>'
        description='<some description>'>
    </jira:CreateIssue>
</JiraJelly>

Next, the cURL:

$username='<user>';
$password='<password>';
$base_url= "http://<your Jira server>/jira/secure/
    admin/util/JellyRunner.jspa";
$params="os_username=$username&os_password=
    $password&Run=Run&filename=&
    script=" . urlencode($<your XML string>);

$curl = curl_init();
curl_setopt($curl,CURLOPT_HTTPHEADER,array('
    X-Atlassian-Token: no-check'));
curl_setopt($curl,CURLOPT_RETURNTRANSFER, false );
curl_setopt($curl,CURLOPT_FOLLOWLOCATION, true );
curl_setopt($curl,CURLOPT_URL, "$base_url?$params");
curl_exec($curl);
curl_close($curl);

Now all you need is to fill in the variables and you’re up and running.

Hope this helps someone out there!

This entry was posted in Uncategorized and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>