Jira Automation with Jira Edge Connector: A Guide to Script Arguments
Platform Notice: Cloud Only - This article only applies to Atlassian apps on the cloud platform.
Summary
Jira automation actions and Jira Edge Connector (JEC) let you automate operations on on-premises systems by sending JSON key-value messages triggered by specific events. This guide clarifies how to structure and use script arguments effectively.
Solution
This article aims to help you understand how to use the automation feature of Jira Service Management with JEC. It's important to know that Atlassian Support can verify whether JEC is receiving information correctly, but we don't provide support for scripting issues. If you need help with scripting or specific use cases, we recommend engaging with the Atlassian Community. There, you can collaborate with other users and experts to share knowledge and solutions. Developing your scripting skills independently will also help you create tailored solutions that meet your specific needs.
Understanding the Script Execution Environment
When an automation action triggers a script via JEC, the system passes several arguments to the script that can be used within it for various operations. The arguments include:
A JSON payload containing data and key-value pairs specified in the automation setup.
An API key in plaintext (use with caution due to security considerations).
The log level.
The API URL.
The position of these arguments can vary based on how the automation is configured. Users must adapt their scripts to correctly identify and use these arguments.
Adapting Scripts Across Different Scripting Languages
Scripts need to be tailored to correctly identify the position of each argument. Below are guidelines for handling arguments in various scripting languages, emphasizing the need for adaptability.
Groovy (.groovy)
// Adjust the index based on the argument's position
def payload = new JsonSlurper().parseText(args[index])Python (.py)
import sys
import json
# Adjust the index based on the argument's position
payload = json.loads(sys.argv[index])Go (.go)
import (
"encoding/json"
"os"
)
func main() {
// Adjust the index based on the argument's position
var payload map[string]interface{}
json.Unmarshal([]byte(os.Args[index]), &payload)
}PowerShell (.ps1)
# Adjust the index based on the argument's position
$payload = $args[index] | ConvertFrom-JsonShell Scripts (.sh)
# Adjust the index based on the argument's position
payload=$(echo $index | jq '.')Batch Files (.cmd and .bat)
@echo off
REM Adjust the index based on the argument's position
set payload=%index%Handling Automation Script Arguments in Python for Jira Service Management
For a detailed example of how to work with the Jira Edge Connector and handle script arguments in Python, please refer to this example script provided by Atlassian on GitHub.
Best Practices and Pitfalls
Security: Handle the plaintext API key argument with care to avoid security risks.
Validation: Jira doesn't validate your key-value pairs; ensure you verify them within your script.
Language Specifics: Familiarize yourself with how each scripting language handles arguments to efficiently extract and utilize the passed data.
Troubleshooting common argument-parsing errors
If a script receives fewer arguments than expected, or the JSON payload argument is empty, first confirm the automation rule's "Send data" configuration actually includes a payload, and that the receiving script's argument index matches the order shown in the automation's execution log (accessible from the rule's audit log), rather than assuming a fixed position across all rule configurations.
Was this helpful?