How to update Epic link based on a custom field value using CLI option ?

Aisha M November 12, 2018

I have a custom field with 4 values. I want to set up a post function at the create transition, which automatically updates the Epic links when a story is createdm based off the value selected for the custom field.

Also, these are 4 epic key, which will never be closed. so it ll be a on going process. 

Can someone please help me with the Bob Swift CLI command for establishing this. Thank you 

3 answers

0 votes
siva September 3, 2019

@Antoine Berry @[deleted] 

 

Hi Antine ,

 

I have a request  to update EPIC  (End date) , Depending on the completion date of the last story in the Epic.

Any post functions that could achieve this (or )  any script functions available.

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 4, 2019

Hi @siva , I would suggest you open a new question you will have much more visibility.

Antoine

0 votes
Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 16, 2019

Hi @Aisha M ,

Could you please thoroughly explain your need ? How many custom fields do you have, what types, what issue types and what do you want to achieve ?

Also, I do not own Bob Swift CLI at the moment so would ScriptRunner be an option ?

Antoine

Aisha M May 22, 2019

@Antoine Berry Just in case you are interested :)

Yes ! scriptrunner would be great too . . I think we need to add the script at the create step of the Project workflow. 

Below is the scenario.

We have a Service Desk project, where they want to automatically populate EPIC LINK values based on a CUSTOM FIELD VALUE selected during the ticket creation phase.

Basically, automate the population of “Epic Link” from the value selected in the “Work Request Type” field 

Work Request Type = Epic Link

  1. Common Layer Merge Request = (PEAGACOE-13)
  2. Design Review =  (PEGACOE-30)
  3. Pega Research =  (PEGACOE-20)
  4. Other = (Null Value)

Also, these epic links are constant, wont keep changing :)

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 22, 2019

If I understood well, Work Request Type is a select list (Single value) ?

Also, are you using Epics in a service desk project ? Seems more like a software project right ?

Antoine

Aisha M May 22, 2019

Thank you for the comment ! 

Yes, its a select list (Single Value) field. And the field has just those 4 values. And the Epic links are constant too

Sorry, yes, its a software project.  

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 23, 2019

Hi @Aisha M ,

Please find the script below. I have added a Map so that you can change/add/remove values easily if need be (remember that the select list values and the epic keys must match perfectly). With the current behaviour, if the user picks "Other", or nothing at all, the epic link is not updated. That can be modified if you want.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import org.apache.log4j.Logger
import org.apache.log4j.Level

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def epics = ["Common Layer Merge Request": "PEAGACOE-13",
"Design Review": "PEGACOE-30",
"Pega Research": "PEGACOE-20"]

def workRequestTypeId = 11004
def workRequestType = customFieldManager.getCustomFieldObject(workRequestTypeId)
def workRequestTypeValue = issue.getCustomFieldValue(workRequestType)

def epicLinkId = 10101
def epicLink = customFieldManager.getCustomFieldObject(epicLinkId)
def epicLinkValue = issue.getCustomFieldValue(epicLink)

def epicToSet = issueManager.getIssueObject(epics[workRequestTypeValue?.getValue()])

if (epicToSet){
epicLink.updateValue(null, issue, new ModifiedValue(epicLinkValue, epicToSet), new DefaultIssueChangeHolder())
}

Antoine

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 28, 2019

Hi @Aisha M ,

Did this work as you expected ?

Antoine

Aisha M June 24, 2019

@Antoine Berry  Thank you for taking the time to work this out :) Really appreciate it . . I was out of work for some days , so couldn't test it out. Planning to try your script now *fingers crossed* :D 

Like Antoine Berry likes this
Aisha M July 4, 2019

@

Hi Antoinie @Antoine Berry  It did not work unfortunately :( Maybe I m doing it wrong . . 
The field is in service desk, so do I need to do something different ? Thank you 

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 5, 2019

Hi @Aisha M ,

You mean on the servicedesk portal ? It seems like a software project since you have epics. Also, could you please provide the logs (otherwise it is hard to debug from there) ? 

I remember testing this and it worked fine, so we should find a way.

Aisha M July 5, 2019

@Antoine Berry  Hi :)

Actually, the Epics are in a different project. And the fields are in a service desk project.

Maybe I ll try this out in a new project, with the Epics in the same project, to see how it works. 

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 5, 2019

Make sure the behaviour triggers correctly on the current projet first, by adding a log line in the code. Then check for errors :)

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 4, 2019

@Aisha M Makes me wonder, did you make this work ?

0 votes
Deleted user November 23, 2018

Hi @Aisha M,

 

Yes, you can use the "CLI action"post function from "Run CLI actions fo JIRA" to implement this functionality. Make sure to place the post functions below the native "Re-index an issue to keep indexes in sync with the database." post function in the story workflow. See the example below for reference :

runcli.png

You may need to put 4 post functions for each value in the field.

 

Thanks,

Swathi

Aisha M November 27, 2018

@[deleted] Thank you so much Swathi.

 

So from the sample you had shared , 'RC-1' is the epic link ID is it ? Also, where do I specify the custom field value for the corresponding Epic Link ? 

Deleted user November 27, 2018

Hi @Aisha M,

 

Yes, RC-1 is the EPIC issue key. 

For adding custom fields, you can use --custom parameter. See the sample action which updates two custom fields namely "isExternal" and "RandomField".

--action updateIssue --issue "%original_key%" --server %base_url% --user admin --password admin --field "Epic Link" --value "RC-1" --custom "isExternal:Yes,RandomField:abh"

Thanks,

Swathi

Aisha M November 27, 2018

@[deleted]

As an example, I m trying this scenario with a custom field that has two values - Text 1 ; and Text 2.

If issue created with field value, "Text 1" , the epic ID should be STP-824

If issue created with field value, "Text 2", the epic ID should be STP-825

Can you please help with framing the action for this scenario please. I have been struggling with this for so long. 

Deleted user November 28, 2018

Hi @Aisha M,

For validating the value of the custom field, you can use "Condition" section at the top in the post function. See the screenshot below :

epicid.png

Hope you are using RUN CLI actions for JIRA and not JIRA command line interface.

Thanks,

Swathi

Aisha M November 29, 2018

@[deleted] Really appreciate you helping :)

Well, unfortunately does not work :(

I tried adding a post function at the create transition (so that once an issue is created, the issue is automatically undated with the epic link based on the field value)

Condition 1 -  %original_customfield_14100%   Pattern - Text1

Action - -a run --server %base_url% --options basicAuthentication --user "Automation" --password "****"

Data - --action updateIssue --issue "%original_key%" --field "Epic Link" --value "STP-824"

 

 

Any idea why it ain't working ? Thank you

Aisha M December 5, 2018

@[deleted] Your thoughts please. Thank you 

Deleted user December 8, 2018

Hi @Aisha M,

 

Your post function seems to be correct. However, I suspect that you might have placed the post function in the first place (in create transition). Can you confirm if the order is in the correct place? Make sure to place it after the "Re-index an issue to keep indexes in sync with the database." post function.

If you still see any issues, please raise a support request here so we can take a look at the debug logs.

Thanks,

Swathi

Aisha M December 10, 2018

@[deleted] Hi Swathi,

I have placed it below the "Re-index an issue to keep indexes in sync with the database." post function". 

Any other reason it could be failing ?

Thank you

Deleted user December 13, 2018

Hi @Aisha M,

 

Please raise a support request here so we can take a look at the logs and debug.

 

Regards,

Swathi

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events