Code Repository

As our favorite app capability (so far), the Code Repository allows you to reuse code around your Post Functions, Listeners and Console.

Creating a Demonstrative file

Go to Easy for JiraCode Repository (left menu).

You can create files that can be imported to other places, so let’s work one example, we want to centralize this sum function so we can call it on other scripts.

Name

Prettify Seconds

Name

Prettify Seconds

Filename

seconds_prettify.py

Documentation

Function to receive an integer (seconds) as input and make it more humane.

def prettify_seconds(seconds): days = seconds // (24 * 3600) seconds %= (24 * 3600) hours = seconds // 3600 seconds %= 3600 minutes = seconds // 60 seconds %= 60 result = "" if days > 0: result += f"{days} day, " if days <= 1 else f"{days} days, " if hours > 0: result += f"{hours} hours, " if minutes > 0: result += f"{minutes} minutes, " result += f"and {seconds} seconds" return result

When you hit save , your file will be available to all scriptable modules of the app such as Post Functions, Listeners and Console.

Above the “Save File” button there’s the import declaration that you need to add to your files, so let’s suppose I want to use this sum function on my postfunction to sum 2 fields. I would go to Post Functions then in the beginning of my file I would add:

import seconds_prettify
Screenshot 2024-05-11 at 22.19.31.png

Usage

When creating or updating your Post Functions or Listeners you can import your code as:

import seconds_prettify seconds = 89219 string = prettify_seconds(seconds) print(string) # Output :: 1 day, 46 minutes, and 59 seconds

This is of course a very basic example, as you can build whatever you want and import it to other files.

Documentation

The documentation can be written in a markup format, and then put in a readonly format by clicking in the eye Screenshot 2024-05-11 at 22.25.12.png so it’s readable.

 

 

image-20240512-012557.png

 

image-20240512-012424.png
Markup Editor powered by EasyMDE

 

 

The final editor should look something like this:

image-20240512-012354.png

Versions

Dealing with Versions is quite easy, below your editor you can see some arrows pointing backwards.

image-20240512-012722.png

 

 

To load a version is simple, click the arrow. It should load only the version of the code.

 

Easy for Jira - Python Automations, 2023