Jira Automation: Create Sprint Action

Dennis Kugelmann March 30, 2020

Is there some way to create a sprint in Jira Automations?

What I want to achieve is:

Sprint 23 gets completed
-> Sprint 24 (already existing) will get the Current Sprint
-> New Sprint (Sprint 25) gets created for the week after Sprint 24.

So we always have two sprints the currently active one and the next one for bugs which have to be done in the next sprint.


2 answers

2 votes
Guy Anela November 8, 2022

Hi @Dennis Kugelmann - You should theoretically be able to accomplish this by using the Send web request Action. Once to GET the current Future Sprint info, then POST to Start the future sprint, and another POST to create a new future sprint. Something like this...

  1. Trigger: Sprint Completed

  2. Action: Send web request (to Get the Future Sprint)
    • GET /rest/agile/1.0/board/[YOUR BOARD ID]/sprint?state=future

  3. Action: Create variable (to store the future Sprint Id from the web response):
    • Name: FutureSprintId
    • Smart value: {{webResponse.body.values.id}} 

  4. Action: Send web request (to Start the Future sprint):
    • POST /rest/agile/1.0/sprint/{{FutureSprintID}}
    • Custom data (in JSON format):
      {
      "state": "active"
      }

  5. Action: Send web request (to Create a new Future sprint):
    • POST /rest/agile/1.0/sprint
    • Custom data (in JSON format):
      {
      "originBoardId": {{BoardID}},
      "goal": "",
      "name": "{{NewSprintName}}",
      "startDate": "{{NewSprintStartDate}}",
      "endDate": "{{NewSprintStartDate.toDate.plusWeeks(1)}}"
      }

I say "theoretically" because I haven't actually tested it. :) However, I do have a similar "Scheduled" Automation that successfully creates two Future Sprints if none exist.

Anyhow, I hope this helps get you (and others) pointed in the right direction. Cheers!

Pfohl Jason February 22, 2023

@Guy Anela Can you share the "Automation that successfully creates two Future Sprints if none exist." I am trying to accomplish this but have errors from my URL. 

Thanks

Guy Anela February 22, 2023

 

Hi @Pfohl Jason - It sounds like your Web request might not be configured correctly. Can you post a screenshot of it?

Here's an example of what my first web request looks like...
AutomationExample-GetSprintWebRequest.png

Like Dave Furlani likes this
Dave Furlani June 19, 2023

@Guy Anela , would you be so kind as to share a similar screenshot of your POST that creates the future sprint. The screenshot above is for the GET and I'm having trouble with the body of my POST (405s and 401s). 

My POST conforms to the description here https://community.atlassian.com/t5/Jira-Software-questions/set-up-automation-creating-new-sprint/qaq-p/1929573 

Thanks

Guy Anela June 20, 2023

Hi @Dave Furlani - Here's the screenshot of the POST configuration. I'm guessing it has something to do with your Authorization Header value...

AddSprintsPostExample.png

 

I hope this helps. Cheers!

Dave Furlani June 20, 2023

You may be right. I had my event with a POST formatted like the above, and I get a 401 error about authentication (with a GET using the same token I get a 405 about the HTTP body).

Error response HTTP body:
{"message":"Client must be authenticated to access this resource.","status-code":401}

 

I'm getting the API token from here - https://id.atlassian.com/manage-profile/security/api-tokens (for those working through similar automations, this is the correct source). Is there a 3rd party parser I'm meant to use to turn it into Base64?

Guy Anela June 21, 2023

Sorry, @Dave Furlani , I wasn't as clear as I should have been in my previous post. :)

The BASE64 encoded value should include the username (email), a colon, and the API Token (e.g. user@email.com:3nDt7787879wxyz123).

You can use any BASE64 Encoder. If you encode the above example, you should get...

dXNlckBlbWFpbC5jb206M25EdDc3ODc4Nzl3eHl6MTIz

Here's an example using https://www.base64encode.org/...

EncodedExample.png

 

That's the value you want to put after the "Basic " in your Web Request Header...

EncodedExample2.png

I hope this helps to clarify things. :)  Cheers!

Dave Furlani June 21, 2023

@Guy Anela you have nothing to apologise for - you have been extremely helpful.

Why Atlassian don't provide/use a key in the format they use/provide, not suggest it's needed and advise to add in the automation email address in the UI is a little frustrating, but I digress.

To that end thread will also be useful to people having the same trouble in future - https://community.atlassian.com/t5/Jira-Service-Management/What-is-the-email-address-of-automation/qaq-p/1791176

Like Guy Anela likes this
Dave Furlani June 21, 2023

That said, I'm still getting 401 errors. 

I created the Base64 key with the email address A4J sends emails from, colon, the API token I created. I also added the A4J user to the permission scheme with Manage Sprints rights, although "All logged on users" was already there.

I can see that the relevant token seems to be being used and accessed by Jira when the web requests are sent. At least I assume I wouldn't see that it had been accessed if the key wasn't correct, so I assume I converted that key to Base64 correctly. This only updates sometimes regardless of the address used (see next para). 

I also tried converting the key with each of the email addresses I've received from Jira in the past, just to cover all the user account bases:

  • automation@XXXX.atlassian.net 
  • no-reply@automation.atlassian.com 
  • jira@XXXX.atlassian.net 

I'm not sure what else to try, so I've provided the full error from the logs below in case that provides some useful context.

 

download.png

e89d0929-92c7-402b-a580-0fc900b791ad.png

download.png

Guy Anela June 22, 2023

Hey @Dave Furlani - Just to confirm, make sure you're using the email address of the account you used to create the API Token. 

Also, make sure you put a colon (:) between the email address and Token before you encode it (e.g. user@email.com:3nDt7787879wxyz123). ...nevermind, re-read your response and saw that you did that already. :)

Like Dave Furlani likes this
Dave Furlani June 22, 2023

Bingo. We have a winner. That did the trick

Thanks @Guy Anela 

Like Guy Anela likes this
0 votes
Stephen Wright _Elabor8_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 12, 2020

Hi @Dennis Kugelmann

I don't think this will be possible using Automation for Jira.

This is because actions within Automation are project and issue-based. Sprints are neither, these are board-based and can apply to one or multiple projects.

If you were to "create" new sprints via Automation for Jira it would need to be possible to create them from the field itself on an issue, which is not possible - the field is just a representation of all the sprints created on boards.

You'd need to consider whether this is possible via the API or a scripting app instead (but it's not something I've come across before, I'm afraid).

Ste

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events