Hi everyone, so whilst technically my automation is working it is bloated and likely far more complicated than it should be.
For talks sake, what I am trying to achieve is to have the summary of every new ticket searched for a countries name OR countries possessive name OR top level domain, this is for a list of around 40 countries, so around 120 strings. From there I want it to create a label that includes the country name.
Currently my automation workflow looks like:
Country 1
- issue fields condition: Field(summary) Condition (Contains) Value (Germany)
- Then: Edit issue fields: Labels(Germany)
- issue fields condition: Field(summary) Condition (Contains) Value (Germany's)
- Then: Edit issue fields: Labels(Germany)
- issue fields condition: Field(summary) Condition (Contains) Value (.de)
- Then: Edit issue fields: Labels(Germany)
Ideally I'd rather it ran like:
Country 1
- If: any match; Summary contains Germany OR Germany's OR .de
- Then: Edit issue fields: Labels(Germany)
Hi @Rory Gould
From what you have described for your use case, you are trying to do this in an Automation for Jira rule. Is that correct?
If so, this will not work with that many countries. An automation rule can only have 60 components (trigger, actions, branches, conditions), and your rule would need at least:
You do not show an example of your actual summary fields, and I wonder if instead you could do part of this use case with regular expression matching in a more generic manner...using less than 10 components.
One challenging part is you want to translate the 2-character country code to the country names. Another is that you could run up against other automation limits; perhaps there is a maximum length string for a regular expression in this tool.
I suggest pausing to reconsider this problem and determine if there is a way to get the country information into its own field when the issue is created. You do not indicate the source of the issues so it is unclear if that is an option.
Kind regards,
Bill
Hi Bill, thanks for the reply. I'm not too hot with using the advanced/compare function/regular expression function and am not sure how I would complete it. Something like
{{issue.summary}}
contains
???
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Again, I first recommend trying to get the data into a dedicated field to eliminate the need for parsing.
After a quick test, you may only partially be able to solve this as the regular expression parser for automation rules does not appear to implement word boundaries. So you could find "Germany" and "HeresGermanyCountry".
I tested an expression like this with a very long 200+ country string I built, and it successfully found the string, which I put into a Created Variable for later use. Here's an example with just four countries.
{{issue.summary.match(".*(Germany|France|Italy|Spain).*")}}
The country name checks is probably going to be okay for your needs. The 2-character country code is probably a non-starter due to the missing word boundary support: that will match on many strings potentially.
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.
You are using the contains operator, so contains Germany and contains Germany's is ambiguous, once contains Germany match Germany and Germany's, right?
But put .de in the same condition idk how to do, idk where this automation is running (my groovy, workflow, scriptrunner...)
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.
Right. You can to do it with a simple post function script, like below:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
def labelManager = ComponentAccessor.getComponent(LabelManager)
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def matches = ['germany','.de']
def newLabel = ['Germany']
if (issue.summary.toLowerCase().contains(matches[0]) || issue.summary.toLowerCase().contains(matches[1])){
def existingLabels = labelManager.getLabels(issue.id)*.label
def labelsToSet = (existingLabels + newLabel).toSet()
labelManager.setLabels(user, issue.id, labelsToSet, false, false)
}
set this script as Groovy inline script on your workflow step
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.
Try then let me know if this works!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.