best ways to use automation for JIRA
Asked by Aravind Koushik Gobburu:

Hi i am new to Automation for jira plugin. Is there any documentation available like best practices to use Automation for jira available. I have googled it but couldn't find an exact document. Here is what i found while googling.

1.<https://confluence.atlassian.com/automation/concepts-993924598.html.(Mostly> the concept is explained here)  
2.<https://support.atlassian.com/cloud-automation/docs/best-practices-for-optimizing-automation-rules/(Best> practices for optimizing automation rules).

Can anybody give me a perfect document for best practices for using Automation for jira plugin.

Thanks in advance.


Answers:
author: Bill Sheboy
body: Hi [@Aravind Koushik Gobburu](/t5/user/viewprofilepage/user-id/4224125)

I do not believe there are "best" practices for any tool; only better ones. How your teams use it depends on what your teams need to support Jira usage.

Here are some things I have found may help with automation usage:

* There is no configuration management with rules, so implement your own. For example, create a Confluence page to document your rules and changes over time.
* Regularly export all of your rules as site admin to back them up. There does not appear to be a way to backup rules with Atlassian provided backups.
* Add at least one global rule to monitor usage for SLA limits. Have it email your admins when approaching the limits.
* Automation rules can have synchronous and asynchronous processing, so when possible try to use a simple rules or divide-and-conquer approach by issue type to reduce complexity and improve predictability. This will make maintenance and diagnostics easier.
* Follow the articles, posts, questions in the automation area to learn about changes/issues: [Jira Automation - Atlassian Community](https://community.atlassian.com/t5/Jira-Automation/ct-p/automation)
* Create a test project to exercise rules \*before\* putting them in a team's production project. Better still, create a free Jira instance to test rules. As with most of Jira Cloud, there is no "undo" function and so a broken rule could quickly cause lots of damage.
* Learn the names of the smart values in your instance, especially for the custom fields your admins have added. To find them, please take a look at this article: <https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/>
* Here is a article from Atlassian which lists many useful sources: <https://community.atlassian.com/t5/Automation-articles/Jira-Automation-all-the-resources-you-need-in-one-page/ba-p/1388465>
* Go forth and experiment. In general with a test project, you will not break things in Jira with an automation rule. So try what you want to do, and if you get stuck post images of your rule and audit log for the community to help.

Kind regards,  
Bill

comments: author: Darryl Lee
body: These are all really good tips, [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

Both Documentation and Backups are a really good idea.

Once you have that backup file (example: automation-rules-202201121937.json), this [jq](https://stedolan.github.io/jq/) comand will extract Name, Description, Status (enabled or not), ID, Project ID, and Trigger Type and convert it to a CSV, which could be imported into Excel or Google Sheets, which would be a great starting point for documentation:
> jq -r '.rules\[\] \| \[.name, .description, .state, .id, .projects\[0\].projectId, .trigger.type\] \| @csv' automation-rules-202201121937.json \> rules.csv

So **rules.csv** will look like this:

```
"Add request participants",,"ENABLED",1819286,"10001","jira.manual.trigger.issue"
"Advanced comparison",,"ENABLED",2598558,,"jira.issue.event.trigger:worklog"
"Approvers to Watchers",,"ENABLED",2361087,,"jira.issue.field.changed"
"Assign to First Commenter",,"ENABLED",1578948,"10001","jira.issue.event.trigger:commented"
"Changelog / Multiselect fun",,"ENABLED",1567973,"10001","jira.issue.field.changed"
```

One problem with this is that you'd need to look up Project ID. If you export the list of Project and IDs this is pretty easy to do with a lookup table in Excel or Google Sheets.

To get list of Projects and IDs (50 at a time):  
<https://YOURSITE.atlassian.net/rest/api/3/project/search>

(API details: <https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-projects/#api-rest-api-3-project-search-get>)

If you save that as a file (projects.json), jq lets you convert that output into a CSV with ID and Project Name, which would work great as a lookup table:

```
jq -r '.values[] | [.id, .name] | @csv' projects.json > project.csv
```

I could write a whole article on JSON and Automation Rules... (It's been in the works for a while. :-)


author: Darryl Lee
body: Another idea that I've not actually implemented is using jq to just nicely format the JSON from the export file, and then checking that into a source code repository tool like Bitbucket or Github. (This command would just be:

```
jq -r '.' automation-rules-202201121937.json > formatted-rules.csv
```

If you did uploaded each backup as a new version, you would be able to use built in tools to see changes/differences as you add/edit rules.

I've done this kind of comparison manually between sandbox and production environments and it was helpful in looking for errors in complex rules.


author: Vishwas
body: Hey [@Aravind Koushik Gobburu](/t5/user/viewprofilepage/user-id/4224125)

Please check this out Best Practices Link about Automation for Jira Plugin <https://blog.codebarrel.io/10-tips-best-practices-to-get-started-with-automation-for-jira-b423e6868595>

Also take look at Automation Library here <https://www.atlassian.com/software/jira/automation-template-library>

Regards,

Vishwas


Tags: cloud

data-center