Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically Create Issue on Sprint Start and add to current Sprint

Omar Rashid November 1, 2018

Is it possible through scripting somehow to have an issue automatically created and added to a sprint when the user has started the sprint, through scripting? Thanks for any feedback you guys can offer!

2 answers

0 votes
Hadas Hamerovv
Contributor
August 29, 2021

Ok. Here is how we managed to do that:

1. Create a script listener and set the triggering event for a 'sprint start'

2. In the Script Context console write the following:

NOTE - Replace the following strings to your own ones:

'your-project-key' - to your project key name

'IssueType' - to the issue type you are trying to add (i.e Bug, Feature, Task etc.)

summary and description - write whatever you want. In our case we added the sprint name to the issue name thus you see the @$sprintName

Hope This helps

 

def projectKey = 'your-project-key'
def projectId = get("/rest/api/2/project/${projectKey}").asObject(Map).body.id

def taskType = get("/rest/api/2/issuetype/project?projectId=${projectId}").asObject(List).body.find { it['name'] == 'IssueType' }['id']
def sprintName = sprint.name


post("/rest/api/2/issue")
.header("Content-Type", "application/json")
.body(
[
fields: [
summary : "$sprintName - task-name",
description: "Commit all the subtasks which are done in $sprintName (Bug fixes and New Features) to Staging",
project : [
id: projectId
],
issuetype : [
id: taskType
]
]
])
.asString()

0 votes
Hadas Hamerovv
Contributor
August 27, 2021

Wow, I have the same problem and can't figure out how to code this. I am reading all the ScriptRunner tuts and still am confused. Will let you know if I manage to do that

Suggest an answer

Log in or Sign up to answer