Skip to content

Instantly share code, notes, and snippets.

@silverjam
Created February 6, 2020 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silverjam/3cd0c0832a69fcd5e24095c2e0921026 to your computer and use it in GitHub Desktop.
Save silverjam/3cd0c0832a69fcd5e24095c2e0921026 to your computer and use it in GitHub Desktop.
JIRA scripting with Python
from jira import JIRA
server = "https://swift-nav.atlassian.net"
api_key = open('jira_api_key.txt').read()
# print(api_key)
basic_auth = ('jason@swift-nav.com', api_key)
# Query string for the cloned issues:
query_str = 'project = INFRA AND issuekey >= INFRA-77 AND issuekey <= INFRA-83 AND creator = currentUser()'
# The key of the cloned epic
epic_id = 'INFRA-76'
jira = JIRA(server, basic_auth=basic_auth)
issues = jira.search_issues(query_str)
issue = issues[0]
# Dump an example issue
print(issue)
epic_issue = jira.issue(epic_id)
template_issue = jira.issue('INFRA-64')
# Print the parent link of a template issue
print(template_issue.fields.parent)
# Setup links for all the issues in the cloned epic
for issue in issues:
issue.update(fields={"parent": {"key": epic_issue.key, "id": epic_issue.id}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment