How to manage Jira issues (create, edit, comment etc) programmatically

George Makos December 28, 2011

Hi there!

I'm new to Jira Development and I'm a bit confused on how can I manage Jira issues programmatically.

My goal is to create a windows application (prefferably using microsoft tools -C#/VB.NET etc-) with the functionality of creating and editing a Jira issue.

I've searched for possible solutions but couldn't find something suitable to my requirements.

So if there is any link for guides or tutorials regarding issue management through code, I would appreciate it if you could let me know..

Thanks in advance

George

4 answers

0 votes
Renjith Pillai
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.
October 17, 2012

As far as I undertand about using SOAP using Visual Studio C# (with any version for that matter), do an auto generation of code by importing the WSDL from your local jira or even one of the publich JIRA instances (same version) and directly using the generated classes. I have no clue about atlassian.jira.dll, I have not used it.

And if you business logic requires that you trigger JIRA, then SOAP or REST is fine. But if you need JIRA to trigger you, either you should write a plugin, or use the latest method of Webhooks (in labs) which can trigger you via JSON data during issue changes.

And regarding, when/how you write a plugin, read https://developer.atlassian.com/display/HOME/Welcome

Praveen October 17, 2012

Renjith,

What do you mean by "do an auto generation of code by importing the WSDL from your local jira or even one of the publich JIRA instances (same version) and directly using the generated classes." How can I do that?

Regards

Praveen.

Renjith Pillai
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.
October 17, 2012

Praveen, check http://lmgtfy.com/?q=access+a+web+service+visual+studio+wsdl

0 votes
Alex Kersha January 30, 2012

VB.Net methods (Don't forget that JIRA is a case sensitive instance and the JIRA issue key MUST be upper cased when using methods)

This should get you started

'JIRA specific variables
    Private JiraSoapService As New JiraSoapServiceService
    Public JIRA_token As String = ""
    Public JIRA_userName As String = ""
    Public JIRA_password As String = ""
    Public JIRA_status As String = ""
    Public JIRA_key As String = ""
    Private Const JIRA_ProjectStr = "TECH"

'JIRA specific functions and Subs
    'Connect & login
    Sub JIRA_Connect()
        JIRA_token = JiraSoapService.login(JIRA_userName, JIRA_password)
    End Sub
    'LOGOUT
    Sub JiraLogout(ByVal JIRA_userName As String)
        Try
            JiraSoapService.logout(JIRA_userName)
        Catch ex As Exception
            'Nothing to do if there is an error.
            'Maybe the user is already disconnected because of the session timeout.
        End Try
    End Sub
    'Return a JIRA issue by ID
    Function JIRA_getIssue(ByVal issueKey As String)
        Dim theJiraIssue As RemoteIssue
        Dim theJiraProject As RemoteProject
        Dim remoteUser As RemoteUser = JiraSoapService.getUser(JIRA_token, JIRA_userName.ToLower())

        If Trim(remoteUser.name) <> "" Then
            'Set the JIRA project type
            theJiraProject = JiraSoapService.getProjectByKey(JIRA_token, "TECH")
            'Get the Issue structure
            theJiraIssue = JiraSoapService.getIssue(JIRA_token, issueKey.ToUpper)
            JIRA_key = theJiraIssue.key
            'Set the status string
            For Each remoteStatus As RemoteStatus In JiraSoapService.getStatuses(JIRA_token)
                If remoteStatus.id = theJiraIssue.status Then
                    JIRA_status = remoteStatus.name
                End If
            Next
            Return theJiraIssue

        Else : Return vbNull

        End If

    End Function

Alex Kersha January 30, 2012

Here's a method for adding a comment:

Private Sub butSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butSave.Click
        Dim theComment As New RemoteComment

        Try
            theComment.author = theUser
            theComment.body = tbComment.Text
            theComment.created = Date.Now

            JIRA_setIssueComment(theComment)

            theSubmitResult = 1
            Me.DialogResult = DialogResult.OK
        Catch ex As Exception
            MsgBox(ex.Message, , "Error saving comment")
            theSubmitResult = 3
            Me.DialogResult = DialogResult.Abort
        End Try

    End Sub

'Add comment to JIRA issue
    Sub JIRA_setIssueComment(ByVal theComment As RemoteComment)
        JiraSoapService.addComment(JIRA_token, JIRA_key, theComment)
    End Sub

0 votes
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 29, 2011

Interacting with the JIRA SOAP services via C# is pretty straight-forward. The one important "trick for beginners" to note is that the WSDL file generated by JIRA is incompatible with the .NET WCF Client in .NET 3.0 and greater. To successfully generate client classes for .NET you need to use the older .NET 2.0 wsdl generator (in Visual Studio that's a "Web Reference" rather than a "Service Reference", or using the command line wsdl.exe tool).

For a leg-up on building out the client classes, have a look at https://bitbucket.org/farmas/atlassian.net-sdk/wiki/Home and https://bitbucket.org/MikeJansen/jirarestclient.net/wiki/Home

George Makos January 2, 2012

thanks for your reply Joseph

i'll checkout the links you posted (and probably return with more questions :) )

George

FedericoA January 3, 2012

In addition to the .NET SDK that Joseph mentions above, you might also find this useful: https://bitbucket.org/farmas/jiratrayapp. It is a windows tray application to create JIRA issues (written in C#).

- Federico

0 votes
Jobin Kuruvilla [Adaptavist]
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.
December 28, 2011

Checkout https://developer.atlassian.com/display/JIRADEV/JIRA+RPC+Services

REST is the preferred way as it is improving lot in the later/upcoming versions. JIRA 5.0 has big improvements with REST.

Jobin Kuruvilla [Adaptavist]
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.
December 28, 2011

REST is not supported for creat/update/delete in 4.1. You might want to look at SOAP.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 28, 2011

Yes, but it's not as advanced as Jira 5.0.

George Makos December 28, 2011

i forgot to mention that in my company we use Jira v4.1

Is REST applicable to this version?

George Makos December 28, 2011

Thanks for your reply

As i can see soap will be the right way to implement my application....

Does anyone know if there are any examples of using soap services within c# or VB.NET?

Renjith Pillai
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.
December 28, 2011
That's pretty straight forward, import the wsdl using Visual Studio and get going. The examples at Atlassian documentation, I guess, python, but usage in C# is similar.
Praveen October 17, 2012

Hi Renjith,

Could you please tell me how I can import the wsdl? I'm in real need of it.

Thanks and Regards

Praveen

Praveen October 17, 2012

Hi Jordan,

Thanks for your reply. But could you be more expalanative. Also, please mention any reference materials for the same.

Regards

Praveen.

Jordan Koppole October 17, 2012

REST is not supported as a platform but you still can create your own APIs and deploy it.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 17, 2012

I'm not familiar with Visual Studio, but I suspect reading the docs for it will get you a much faster answer than hoping that someone here knows VS well enough to walk you through it, spots your comment and takes the time to answer.

Jordan Koppole October 17, 2012

You can create the REST api required what you think will do the job and the REST API can be called from any client. It is reqular as any other plugin.

Renjith Pillai
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.
October 17, 2012

Praveen, I hope you read the comment from Joseph Clark below.

Renjith Pillai
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.
October 17, 2012

I am breaking out this to a new answer below.

Praveen October 17, 2012

Hi Renjith,

Thanking you first. I've written a code snipped similar to the one mentioned in https://bitbucket.org/MikeJansen/jirarestclient.net/src/f77556b2be7e/JiraRestClient.Test/JiraRestClientTest.cs

But as I've written this code in VSTA which supports .NET 2.0 framework, the issue arised. The Atlassian.Jira.dll provided by JIRA is of version 4.0.

So, I had to rule out this opiton. I don't know if I'll have to use a plugin to interact with my project. In that case will there be an issue with the version of dlls?

What is the main use of plugin?

Sorry if i'm posting too many questions.

Regards

Praveen.

Suggest an answer

Log in or Sign up to answer