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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,637,431
Community Members
 
Community Events
196
Community Groups

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

Alvin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 06, 2019

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 06, 2019

Hi @Alvin 

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!

Alvin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 16, 2019

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 17, 2019

Hi @Alvin 

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
AUG Leaders

Atlassian Community Events