I, a very green Automation user, am trying to use the Jira Automation plugin to gather details from issues and send them to different email distributions which are based on a component in the issue.
For context, we have a few different api's utilized by different clients. E.g., flavor 1 is utilized by clients A, B, and C, flavor 2 is utilized by clients D, E, F. When we release a version with changes to flavor 1 I want to collect the value from a custom property and send them in an email to a distribution which contains info for clients A, B, C. I would like it if the automation could do this for N (well, up to 200 since I would like to use the lookup table), flavors. It seems like I could get around this by instead creating N different rules for each specific flavor, but this quickly becomes tedious to maintain.
Based the on actions I have available, I want to be able to do the following.
Are we able to loop over the Key in a custom lookup table?
Are we able to access the corresponding Value in a custom lookup table while using a branch/loop?
Is this approach even feasible??!! Am I really better off just creating N individual rules to handle this?
Easy enough...
Easy enough...
How can we iterate over the key a lookup table?
Assuming we can, we will proceed...
Gather all issues using lookup issues JQL where apiflavor property is our custom apiFlavor smart value we are trying to iterate over, and the issue is in our version. Should probably also include a filter for ticket status and resolution...
Only continue if there are issues for this flavor so we don't spam our clients with blank emails...
I would like to pull the value, the email address, from the lookup table. Though I am not sure if this is possible.
As a kicker, I'd also like to send a notification to myself and our deployments group so they are aware that clients have been notified.
Hi @John Maner -
I don't think there is a .keys function for Lookup Tables. That would be pretty sweet.
Instead, I'm thinking you'll have to make a smart value variable with your keys (flavor-1,flavor-2...), and then use .split(",") to iterate through them.
Ah yeah, this seemed to work:
NOW, before you kill yourself trying to create 200 entries in the lookup table by hand (and then also creating that {{keys}} variable manually), I would implore you to take a look at my olde article, Hacking/Parsing Automation Rules with JSON for Fun and Profit.
It's been a while for me, so I looked at the rule I just created, and thankfully, a Lookup Table should be pretty easy to programmatically generate, the key pieces of it being this:
"type": "jira.create.mapping-variable",
"value": {
"name": {
"type": "FREE",
"value": "apiFlavorEmails"
},
"mappings": [
{
"key": "flavor-1",
"value": "flavor-1-deployments@email.com"
},
{
"key": "flavor-2",
"value": "flavor-2-deployments@email.com"
}
]
},
And the {{keys}} smart value variable looks like this:
"type": "jira.create.variable",
"value": {
"id": "_customsmartvalue_id_1694147937774",
"name": {
"type": "FREE",
"value": "keys"
},
"type": "SMART",
"query": {
"type": "SMART",
"value": "flavor-1,flavor-2"
},
So yeah, if I were you, I'd tweak your rule to have the first couple of flavors, then Export that puppy, use the scripting/IDE/spreadsheet of your choice to generate the other mappings and list of keys, hack that into the JSON file, and Import it back in.
Whoo though, 200 different types of APIs? That doesn't sound like much fun to do manually. So yeah, you could probably do the same exercise with Web Requests, etc.
But as always, start small. Test frequently. And have fun!
Ah, split is super clever, thank you!
Also, we don't quite have 200... that's just the most which is supported by the lookup table feature ;)
Appreciate the help!
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.