Hope someone here can help, I've been banging my head against my desk!
i'm using scriptrunner for jira cloud.
1) I have a script listener which fires when a new version is created.
2) My script successfully creates a new issue (story)
How do I create subtasks and link them to the newly created issue?
I thought about creating a new listener which fires after an issue is created and performs a text search for a value which is set when the new version is created, but that seems clunky.
Thanks.
You need to capture the issuekey of the Story you are creating then apply that to the create sub-task example found in the Scriptrunner library. Based on API documentation you should be able to get this on the return from your create. re:
Hope that points you in the right direction.
Thanks Craig. Its the trying to get the issue that I am struggling with. How can I do it on a post, when post is only one way?
I'm using this to create the story issue, which works like a charm:
def issueTypeName = "Story"
def taskType = get('/rest/api/2/issuetype')
.asObject(List)
.body
.find { (it as Map).untranslatedName == issueTypeName } as Map
def taskTypeId = taskType.id
post('/rest/api/2/issue')
.header('Content-Type', 'application/json')
.body([
fields: [
project : [
key: projectKey
],
issuetype: [
id: taskTypeId
],
summary : summary,
priority : [
id: priorityId
]
]
])
.asString().body
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Balhar Bhachu sorry that first response was based on serer/DC.
So for a post it'll be in the response.
From this page:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
once again thanks for taking the time to respond Craig, its greatly appreciated.
I've got this which is working and the variable result contains the json as you described with the id. How do I query the result variable to extract the id?
def result = post('/rest/api/2/issue')
.header('Content-Type', 'application/json')
.body([
fields: [
project : [
id: projectDetails.id
],
issuetype: [
id: taskTypeId
],
summary : "Test story ",
]
])
.asString().body
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have a look at this post.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yayyy, and you're welcome
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.