Create alm defect as sub task in jira

Originally asked by SANDEEP ADE on 21 April 2021 (original question)


Hi ,
i have the following question regarding the alm defect

If I am working on an enhancement ex:enhancement1 and I have two bugs reported for that enhancement ex:BUG1 and BUG2

Now my requirement is to show these two bugs created in alm transfer to jira and shown under Jira parent ticket (either as subtasks ,or links or dependent issues )

How to achieve that ?

Right now all the defects which are created in ALM are transferred to JIRA as a seperate ticket ,but i wanted to show them further under another JIRA parent ticket (which is our enhancement ticket)


Answer by Francis Martens (Exalate) on 21 April 2021

What you can do is set the parent id of the newly created ticket as in

if (firstSync) {
   issue.typeName = "sub-task"

   // assume that 10 is the issue id of the parent
   issue.parentId = 10 as Long 
}

Once that you got this working, you should add the logic to search the parent.
Search can be implemented by instantiating the right Jira services. An example for this is provided in following snippet.


Comments:

SANDEEP ADE commented on 21 April 2021

got the below error

in the above example if parent issue is a string ,what will be the code ?

SANDEEP ADE commented on 21 April 2021

I added the below lines

issue.typeName = “sub-task”
issue.parentId = “DS-42724” as Long

Francis Martens (Exalate) commented on 22 April 2021

You can’t convert ‘DS-42724’ to number because ‘DS-42724’ is not a number …
Do you understand?

the issue.parentId expects the id of the parent. DS-42724 is probably the issue key. So you will have to look up the id corresponding of that issue.

Give it a try.

SANDEEP ADE commented on 22 April 2021

i will pass the Jira parent id from alm (in alm this field is a number) and i want to assign this number to Jira parent id

so what should be the outgoing sync (in alm ) and incoming sync (in jira) ?

i have below two lines but its not working,is the below correct ?

outgoingsync from alm where JIRAParentId is number ex : 10

replica.parentId = issue.customFields.“JIRAParentId”

incoming sync

issue.parentId = replica.parentId as Long