Skip to content

Instantly share code, notes, and snippets.

@ExtremeGTX
Last active February 27, 2019 13:56
Show Gist options
  • Save ExtremeGTX/500a44149428c347b55edae15174a914 to your computer and use it in GitHub Desktop.
Save ExtremeGTX/500a44149428c347b55edae15174a914 to your computer and use it in GitHub Desktop.
Some tips about interacting with Jira APIs (Python)

List all available fields and their info like id, description, etc.

https://myjira.local/rest/api/2/field

Make a transition with mandatory field:

jira.transition_issue(issue, '81',fields={'customfield_XXXXX': "SomeStringValue"}) #Move to State 81 with mandatory field customfield_XXXXX

update multiple fields

issue.update(fields={'customfield_XXX1': "SomeStringValue",'customfield_XXX2': "SomeStringValue"})

Make a transition with mandatory field and its child:

jira.transition_issue(issue, '241',
    fields = {
        'customfield_11470': {
            'value' : 'Инициатива кандидата',
            'child': {'value': 'Вышел на связь с GBC'}
        }
    }
)

update array field

issue.update(fields={"Versions":[{'name':"SomeStringInfo"}]})

Identify issue type

issue.fields.issuetype.id

Add Comment

jira.add_comment(issue.key, "Some comment")

if you can't verify Jira SSL (DON'T DO if you are not understanding the risks)

from jira import JIRA
import warnings
warnings.filterwarnings("ignore", message="Unverified HTTPS request")
options = {
    'server': 'https://myjira.local',
    'rest_api_version': '2',
    'verify' : False
    }
jira = JIRA(options,auth=('user','password')

Reading comments:

jira.comments(issue.fields.parent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment