Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,8 +1034,15 @@ def create_issue(self, fields, update_history=False):
"""
Creates an issue or a sub-task from a JSON representation
:param fields: JSON data
mandatory keys are issuetype, summary and project
:param update_history: bool (if true then the user's project history is updated)
:return:
example:
fields = dict(summary='Into The Night',
project = dict(key='APA'),
issuetype = dict(name='Story')
)
jira.create_issue(fields=fields)
"""
url = 'rest/api/2/issue'
data = {'fields': fields}
Expand Down Expand Up @@ -2479,6 +2486,24 @@ def create_sprint(self, name, board_id, start_date=None, end_date=None, goal=Non
data['goal'] = goal
return self.post(url, data=data)

def add_issues_to_sprint(self, sprint_id, issues):
"""
Adding Issue(s) to Sprint
:param sprint_id: int/str: The ID for the Sprint.
Sprint to be Active or Open only.
eg. 104
:param issues: list: List of Issue Keys
eg. ['APA-1', 'APA-2']
:return: Dictionary of response received from the API

https://docs.atlassian.com/jira-software/REST/8.9.0/#agile/1.0/sprint-moveIssuesToSprint
"""
if not isinstance(issues, list):
raise ValueError("`issues` param should be List of Issue Keys")
url = '/rest/agile/1.0/sprint/{sprint_id}/issue'.format(sprint_id=sprint_id)
data = dict(issues=issues)
return self.post(url, data=data)

def get_all_sprint(self, board_id, state=None, start=0, limit=50):
"""
Returns all sprints from a board, for a given board Id.
Expand Down
3 changes: 3 additions & 0 deletions docs/jira.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ Manage Boards
# Rename sprint
jira.rename_sprint(sprint_id, name, start_date, end_date)

# Add/Move Issues to sprint
jira.add_issues_to_sprint(sprint_id, issues_list)


Attachments actions
-------------------
Expand Down
15 changes: 15 additions & 0 deletions examples/jira/jira-add-issues-to-sprint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from atlassian import Jira

# Issues can be 1 or more
issues_lst = ['APA-1', 'APA-2']
sprint_id = 103

jira = Jira(
url='http://localhost:8080',
username='admin',
password='admin')

resp = jira.add_issues_to_sprint(
sprint_id=sprint_id,
issues=issues_lst
)