Jira ScriptRunner
Jira ScriptRunner is a powerful add-on for Jira, developed by Adaptavist, that enhances Jira's automation capabilities through scripting. It allows users to extend Jira's functionalities with Groovy scripts, providing a flexible way to automate, customize, and extend the capabilities of Jira workflows, issue management, and more. Here are some key aspects and functionalities of Jira ScriptRunner:
Key Features :
1. Automation and Customization:
- Workflow Extensions: Create custom workflow transitions, validators, conditions, and post-functions.
- Scripted Fields: Add custom fields that perform calculations or pull in dynamic data based on scripts.
- Listeners: Automate responses to specific events in Jira, such as issue creation, updates, or transitions.
2. Enhanced JQL (Jira Query Language):
- JQL Functions: Create advanced search queries using custom JQL functions provided by ScriptRunner.
- Scripted JQL: Write Groovy scripts to define complex queries for filtering issues.
3. REST Endpoints:
- Custom REST Endpoints: Create custom REST APIs within Jira to interact with other systems or perform specific actions.
4. Job Scheduling:
- Scheduled Jobs: Set up scheduled tasks to run scripts at specific times or intervals for maintenance, reporting, or data manipulation.
5. Script Console:
- Ad-Hoc Scripting: Test and run scripts directly from the Script Console to see immediate results.
6. Integration with Bitbucket:
- Bitbucket Hooks: Create pre- and post-commit hooks to enforce rules or trigger actions in Bitbucket repositories.
### Common Use Cases
1. Workflow Automation:
- Automatically transition issues based on certain criteria or time-based triggers.
- Validate issue data before transitions using custom scripts.
- Send custom notifications or update linked issues during workflow transitions.
2. Custom Reporting:
- Generate custom reports based on advanced JQL queries.
- Aggregate and display data from multiple issues or projects.
3. Data Manipulation and Migration:
- Automate data updates across multiple issues or projects.
- Perform bulk changes or migrations with custom scripts.
领英推荐
4. Integration and API Extension:
- Connect Jira with external systems via custom REST endpoints.
- Extend Jira’s REST API to support custom business logic.
### Example Script
Here's a simple example of a Groovy script that adds a comment to an issue when it transitions to the "Done" status:
```groovy
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def issueManager = ComponentAccessor.getIssueManager()
def commentManager = ComponentAccessor.getCommentManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Issue issue = issueManager.getIssueObject(issue.id)
def status = issue.getStatus().getName()
if (status == "Done") {
commentManager.create(issue, currentUser, "This issue is now marked as Done.", true)
}
```
### Getting Started
1. Installation:
- Install ScriptRunner from the Atlassian Marketplace via the Jira administration panel.
2. Documentation and Learning:
- Review the official [ScriptRunner documentation](https://scriptrunner.adaptavist.com/latest/jira/) for detailed guides, examples, and best practices.
- Explore the built-in script library for ready-to-use scripts.
3. Community and Support:
- Participate in the Atlassian Community forums to share knowledge and get help from other Jira users.
- Access Adaptavist support for specific issues or advanced customizations.
ScriptRunner significantly expands what you can achieve with Jira, making it an invaluable tool for Jira administrators and power users looking to automate and customize their Jira environment.