Easy for Jira is an app that has a very low entry barrier, to learn and master it, there’s 2 things you need to know, at least the very basics. One of them is of course, Python, and the other is the Atlassian REST APIS. That will unlock at least 65% of what you can do with the app, if you want to expand further, you can study other areas as General API Usage and conventions.
...
Expand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PythonAs Python is the engine behind the app, we need to attach to it’s functionality, below We will list important points to keep in mind while developing using Easy for Jira. A note from the writer: While reading the guide, to fixate your knowledge, go to the app (if you already have it installed) and code along with the guide, test stuff yourself. The only way to learn how to code well is by writing code, unfortunately there’s no shortcut in this part. IndentationPython is a language that can’t be written unstructured such as Javascript, Python reserves scope with text Indentation, which is done by Tabs, this also helps keeping the code more readable. Identation in python is made by 4 spaces or a “Tab”. Indentation is only used when entering some sort of scope such as class declaration, function declaration, loop iterations, etc. NEVER on variable declaration, as the variable should be declared in the same scope, check the reference below.
Global MethodsFrom the segment https://docs.python.org/3.10/library/functions.html in the official documentation, We will skip this part, these functions are almost never used in general cases with a few exceptions. In case you need them, they are available, the functions that are useful from that list are:
And general datatype declarations such as
Data TypesLet’s start with the foundations, first you need to understand the basic Python data types and their methods (functions). Everything in Python is an Object, and all the objects have functions or in the official nomenclature - Methods. Some (almost all) information that will be outlined here is from the original python documentation, no place better to get the information from. Now let’s cut to the chase, the list of data types you can work with in python is the following
Outlining all the functions for all the data types is sort of unnecessary as we have a lot of guides out there, so We will link some resources, with the original docs always available at https://docs.python.org/3.10/library/stdtypes.html# .
StringsStrings are basically text. You are reading a string right now, and everything can be a string in python if you declare it as so. The most basic example so you have “the AHA! moment“ on your head is the following: You declare strings as follows:
But you can also declare a pre-existing number as a string:
You see a number, but the computer now sees a string. Useful links
FloatsFloats, short for floating-point numbers, are a fundamental data type in Python used to represent real numbers. Real numbers include both integers and fractions, providing precision beyond whole numbers. Understanding floats is crucial for working with numerical data and performing mathematical operations accurately in Python. You declare floats as follows:
Similar to strings, you can also convert other data types, such as integers, to floats:
In the above example, although Floats in Python are represented in decimal notation and can contain a decimal point, as well as an optional exponent part indicated by the letter 'e' or 'E'. For example:
It's important to note that while floats provide a high level of precision, they can encounter issues with accuracy due to the limitations of representing real numbers in binary format. Links:
IntegersIntegers are one of the fundamental data types in Python used to represent whole numbers without fractional components. They can be positive, negative, or zero. Understanding integers is crucial for performing arithmetic operations, counting, and representing quantities in Python. You declare integers simply by assigning a whole number to a variable:
Integers can also be the result of mathematical operations:
Integers support various arithmetic operations, including addition (
Python also supports floor division (
And modulo (
Integers in Python have unlimited precision, meaning they can represent arbitrarily large or small numbers without overflowing or losing precision:
You can convert other data types to integers using the
If the string contains non-numeric characters, converting it to an integer will raise a
Understanding integers is essential for performing arithmetic calculations, representing quantities, and manipulating numerical data in Python. Integers are used extensively in a wide range of applications, from simple arithmetic operations to complex mathematical algorithms and data processing tasks. Links:
DictionariesDictionaries in Python are a versatile and powerful data structure used to store key-value pairs. Unlike sequences such as lists and tuples, which are indexed by a range of numbers, dictionaries are indexed by keys, which can be of any immutable data type. Dictionaries are widely used for data organization, mapping, and rapid retrieval of information based on keys. You declare dictionaries as follows:
Each key-value pair in a dictionary is separated by a colon ( You can also create dictionaries using the
Accessing values in a dictionary is done by specifying the key inside square brackets:
If a key does not exist in the dictionary, trying to access it will result in a
Dictionaries are mutable, meaning you can modify, add, or remove key-value pairs after creation. You can modify the value associated with a key:
Add new key-value pairs:
And remove key-value pairs:
Understanding dictionaries is essential for efficient data manipulation and retrieval in Python, especially when dealing with complex data structures and large datasets. They offer fast lookup times and provide a flexible way to organize and access data based on custom criteria. Links:
ListsLists are a fundamental data structure in Python used to store collections of items. They are versatile and widely used due to their flexibility, allowing for the storage and manipulation of heterogeneous data types and providing various methods for accessing, modifying, and iterating over elements. You declare lists as follows:
Lists can contain any number of elements, including zero, and can mix data types:
Elements in a list are indexed starting from zero, meaning the first element is accessed with index
Negative indexing is also supported, allowing you to access elements from the end of the list:
Lists in Python are mutable, meaning you can modify their contents after creation. You can change the value of a specific element:
You can also add elements to the end of a list using the
Or insert elements at a specific index using the
To remove elements from a list, you can use the
Or use the
Lists also support various other operations, such as slicing to create sublists:
And concatenation to combine lists:
Understanding lists is essential for many Python programming tasks, as they provide a flexible and efficient way to store and manipulate collections of data. Lists are used extensively in a wide range of applications, from simple data storage to complex algorithms and data processing tasks. Some useful links about lists:
BooleansBooleans in Python represent truth values, and they are primarily used in conditions and logical operations to determine whether an expression is true or false. Booleans have only two possible values: You can assign boolean values directly to variables:
Booleans are often the result of comparison or logical operations:
You can also use comparison operators like Logical operators such as
Booleans are often used in conditional statements, such as
Understanding how to work with booleans is fundamental for writing robust and expressive Python code. Booleans play a crucial role in decision-making processes and are widely used in various programming contexts, from simple comparisons to complex logical operations. Links:
Those are the main methods you need to master to become a hero on Easy for Jira. About the other methods, if you need to use them, you are probably already falling into a specific audience which already has previous python knowledge and use it professionally. For day to day, Jira Admin use, you won’t need almost any of that. Flow Control (Loops and Conditions)Loops are fundamental constructs in programming that allow you to execute a block of code repeatedly. They are essential for automating repetitive tasks and processing large amounts of data efficiently. Importance of Loops in Coding LogicIn summary, loops play a critical role in programming logic by enabling efficient iteration, automation of repetitive tasks, scalability, flexibility, and the implementation of iterative algorithms. Mastering loop constructs is essential for any programmer looking to write efficient and maintainable code across a wide range of applications and problem domains but you can read in more detail below.
Loop Types
These examples demonstrate the basic usage of each type of loop in Python. Additionally, Python provides loop control statements such as
In this example, for every issue in the JQL results of the query ConditionsConditional programming in Python involves making decisions in your code based on certain conditions. This is achieved using conditional statements, primarily the
The But now let’s suppose you want to foresee two scenarios, what you do then? You use the
The
Switch CaseSwitch Case was added in Python3.10, EFJ is currently running on Python3.9 so you can’t use that yet, once we access and upgrade Python to 3.10, we will add this part of the guide. FunctionsWhat is a Function?A function in Python is a block of reusable code that performs a specific task. Functions provide modularity and reusability to your code by allowing you to define a block of code that can be executed multiple times with different inputs. Function DeclarationTo declare (or define) a function in Python, you use the
Example, let's create a simple function that takes two numbers as input and returns their sum.
Calling a FunctionOnce a function is defined, you can call it by using its name followed by parentheses containing the required arguments (if any). Here's how you call the
Parameters and ArgumentsIn the function definition, the variables inside the parentheses are called parameters. When you call the function, you provide values for these parameters, which are called arguments. Returning ValuesFunctions can return values using the Default ParametersYou can assign default values to parameters in a function. If a value is provided for a parameter during the function call, it overrides the default value; otherwise, the default value is used. Here's an example:
ConclusionFunctions are a fundamental concept in Python programming. They allow you to break down your code into smaller, reusable pieces, making your code more organized, easier to understand, and easier to maintain. Practice creating and calling functions to become comfortable with using them in your Python scripts. ClassesWhat is a Class?In Python, a class is a blueprint for creating objects. It defines the properties (attributes) and behaviors (methods) that all objects of that class will have. Class DeclarationTo declare a class in Python, you use the
Example, let's create a simple class called
Creating Objects (Instances)Once a class is defined, you can create objects (also known as instances) of that class by calling the class name followed by parentheses. Optionally, you can provide arguments to the class's
Accessing Attributes and Calling MethodsYou can access the attributes of an object using dot notation (
Constructor ( |
...
Expand | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Working with Easy for JiraEasy for Jira was designed to reduce effort, but it won’t code by itself ModulesWe do have a few modules to explore in Easy for Jira, such as Listeners and Post Functions, often allied to the use of the Code Repository.
Modules will allow you to put Python code to work on your workflows and events. RecommendationsThe two main recommendations We can outline from my usage/experience with the app are: Both usually are used together. Easy for Jira Wrappers (Context Variables)To do that, we’ve worked out a few wrappers, those wrappers are designed so you use less code, that allows you to
The wrappers we currently have available are outlined here:
Each one will have some specific examples and usage you can explore and use to scale integrations, make your systems more dynamic and your life much easier. We will not explain all of them in detail, just the ones that if you master, you get to the mastery of the app. The Issue ObjectLet’s explore the Issue Object, the main object in Easy for Jira, this class was tailored specially to minimize the iterations from the user to be able to work the issue data, so when you need to edit information from the issue, you don’t have to recur to the API, you can use the If you are using it on Post Functions you can do the following using the issue context:
This block of code will just append some text to your description field. To explain what happened in there, during the transition, Jira communicated with EFJ, which received the issue data and transition data, and performed the action that you asked for, which is to set the description field as description + some more text. This is all made using the APIS, but we created a wrapper so you don’t have to be calling the lower level functionality to do it, as the name suggests, It’s supposed to be Easy. To understand better how the structure of an issue works, you should go to: https://<yourjiracloudsite>.atlassian.net/rest/api/2/issue/<anyissuekey> Replace the placeholders and read the structure of the response, it should look like:
When using the Issue object, the structure you have available is exactly that, so you can get the summary of an issue like this:
or get the labels as a list as follows:
And perhaps you want to get the issue key, or the parent issue key
The API ObjectThe API wrapper allows you to interact with your instance and even to make web requests towards the Jira official API.
The API also allows you to search for issues:
Or iterate them directly:
You can also interact with instance objects such as Projects
Depth Look into Common IssuesOn your day to day as a Jira Admin versed in the arts of Easy for Jira, you will eventually face different problems with the same root resolution. You will generally have to get one or more issues, apply some calculation, treatment, etc and after that, edit one or more issues, those issues are generally related somehow (parent/child, linked) and they will require getting more than one issue to do so. Easy for Jira allows you to handle those problems with ease, so let’s check how you can solve some day to day issues, such as calculating story points for all issues in one epic.
Exercises & ChallengesAs mentioned before, you only really learn code by doing it, so We challenge you to perform 3 levels of challenges to confirm you got the knowledge to use the app. With my past experience, 90% of the time, what you need to know is to handle the trigger issue and his related issues and to do something with them. The following exercises will confirm you can work with Easy for Jira confidently in your day to day. BeginnerThese are entry level exercises, if you can confidently code solutions for the following scenarios, you can consider yourself a
IntermediateThese are mid level exercises, if you can confidently code solutions for the following scenarios, you can consider yourself a
AdvancedThese are advanced level exercises, if you can code solutions for the following scenarios, you can consider yourself a
Once your exercises are done, you can check the Exercise Answers, to check if your approach is the recommended one. |
...