Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to check workflows that uses particular add-on in validators

Hello Community,

Good day! Can someone help me on how can I retrieve workflows that uses a specific plugin/add-on in validators. I'm using this code via Scriptrunner Console but the problem is that it does not display validators, only postfunction is displayed.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.workflow.WorkflowManager
import java.util.regex.Matcher

String searchText = 'descriptor of add-on'

WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager()
Collection<JiraWorkflow> workflows = workflowManager.getWorkflows()

String result = "Workflow;Function;Type;Action;Source-Step<br>"

workflows.each{workflow ->
def workflowXml = workflow.descriptor.asXML()
Matcher m = workflowXml =~ /${searchText}/
if (m.find()) {
String workflow_name = "${workflow.name}${if(!workflow.isActive()){"(inactive)"} else ''}${if(workflow.isDraftWorkflow()){"(draft)"} else ''}"
def wf = new XmlParser().parseText(workflowXml)
List<Node> wf_flat = wf.depthFirst()
wf_flat.each{
if (it.text() ==~ /.*${searchText}.*/){
def nodeInfo = getNodeInfo(it,searchText)
if (nodeInfo){
result += "$workflow_name;$nodeInfo<br>"
}
}
}
}
}
result

String getNodeInfo(Node n, String search) {
String nodetext = ''
def valid_action = false
def valid_function = false
def valid_step = false
if (n.name() == 'function') {
def m = n.value() =~ /[^\[{]*/ + search + /[^\]}]*/
if (m) {
nodetext += m[0].toString() + ";"
}
def p = n.parent()
while (p) {
switch (p.name()) {
case 'post-functions':
valid_function = true
nodetext += "post-function;"; break
case 'validators':
valid_function = true
nodetext += "validator;"; break
case 'conditions':
valid_function = true
nodetext += "condition;"; break
case 'action':
valid_action = true
nodetext += "${p.attribute('name')} (${p.attribute('id')});"; break
case 'step':
valid_step = true
nodetext += "${p.attribute('name')} (${p.attribute('id')})"; break
case 'global-actions':
valid_step = true
nodetext += "GLOBAL"; break
case 'initial-actions':
valid_step = true
nodetext += "INITIAL"; break
}
p = p.parent()
}
}
if (valid_action && valid_function && valid_step) {
return nodetext
} else {
return ""
}
}

 

Thank you!

1 answer

2 votes
Fazila Ashraf Community Leader Jun 06, 2019

Hi @Alvin Parreno 

I came across this wonderful free plugin from Botron - https://marketplace.atlassian.com/apps/1219634/power-admin?hosting=server&tab=overview 

 

Using this, we can analyze usage of a custom field or workflow validator, postfunction, condition given by plugins in the jira instance. see https://botronsoft.atlassian.net/wiki/spaces/PA/pages/883195908/Finding+App+Usage for the details. 

Hope this helps!

Hi @Fazila Ashraf ,

Good day! Thank you for your response, I can clearly say that your suggestion helped us a lot! Furthermore, I also need to know to focus especially on the workflow part, the script above returns the steps on the workflow that is using a particular add-on , but for some reasons, only post-function add-ons are only displayed. Can you help? I also need to display Validators.

Best  Regards,

Alvin

Fazila Ashraf Community Leader Jun 17, 2019

Hi @Alvin Parreno 

For me, the power admin plugin gives the workflows which uses the plugin element as validators also.

And as per the documentation inhttps://botronsoft.atlassian.net/wiki/spaces/PA/pages/883195908/Finding+App+Usage#FindingAppUsage-Usage validators are also reported.

Could you raise a support case with them if its not working for you like that?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Statuspage

New feature: Slack notifications for Statuspage

We're excited to announce the release of a long-requested feature on Statuspage. Now visitors to your status page can subscribe to get notified in Slack when you report an incident or maintenance. Th...

67 views 0 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you