Zatla00
Zatla00

Reputation: 499

JIRA: Update sprint status using python-jira lib

Im' try to create a periodic task that close a print and launch the next.

What I'm planning to do is to find the current Sprint ("state":"ACTIVE") and update its state to ("state":"CLOSED") and take the next Sprint and update it from FUTURE to ACTIVE in a bi-weekly basis.

I can see in the library that we can not update the state of a sprint (this part is commented by default):

def update_sprint(self, id, name=None, startDate=None, endDate=None):
    payload = {}
    if name:
        payload['name'] = name
    if startDate:
        payload['startDate'] = startDate
    if endDate:
        payload['startDate'] = endDate
    # if state:
    #    payload['state']=state

    url = self._get_url('sprint/%s' % id, base=self.AGILE_BASE_URL)
    r = self._session.put(
        url, data=json.dumps(payload))

    return json_loads(r)

My questions is:

Is there a reason for this?

How can I perform this operation in another way ?

Thanks!

Update

I raised a bug and it has been fixed: https://github.com/pycontribs/jira/issues/123

Hope this will help

Upvotes: 3

Views: 1602

Answers (2)

Zaraki Kenpachi
Zaraki Kenpachi

Reputation: 5730

after login to Jira

self.jira = JIRA(server='server', basic_auth=(self.jira_user, self.jira_apikey))

you can update sprint by providing all sprint data :

response = self.jira.update_sprint(id=294, name='name', state='active', startDate=datetime(2023, 6, 24).isoformat(), endDate=datetime(2023, 7, 15).isoformat())

so to change the status simply change the 'state' value

Upvotes: 0

Fr3dBear
Fr3dBear

Reputation: 16

I'm not really sure how you are updating your values but the way I have been updating values is:

    issue.update(status={'name': 'Closed'})

Source: http://pythonhosted.org/jira/

Upvotes: -1

Related Questions