Script Console
The Script Console is an interactive coding environment where you write and execute JavaScript scripts against your Jira Cloud instance. Think of it as a REPL (Read-Eval-Print-Loop) for Jira — you write code, click Run, and immediately see results.
What You Can Do
- Run one-time operations (bulk update issues, fix data, generate reports)
- Test script logic before using it in a listener or scheduled job
- Query data using JQL through HAPI
- Prototype automation workflows
- Debug and experiment with the HAPI API
Interface
The console has three main areas:
- Code Editor — Full-featured editor with syntax highlighting where you write your script
- Output Panel — Shows
console.logoutput, return values, and errors after execution - Action Toolbar — Run button, clear output, and script management options
Writing Scripts
All scripts run in a secure JavaScript sandbox with access to the HAPI library. You can use async/await, modern ES2022+ syntax, and all standard JavaScript built-ins (except DOM APIs — there's no browser here).
Available Globals
| Global | Description |
|---|---|
WorkItems |
HAPI module for issues — create, search, update, transition |
Users |
HAPI module for users — lookup, search |
Groups |
HAPI module for groups — get, create, manage members |
Spaces |
HAPI module for projects — get, list, create |
console |
Logging — log, warn, error (output appears in the panel) |
makeRequest |
Make HTTP requests to Jira REST API endpoints |
Example: Find All High-Priority Bugs
const bugs = WorkItems.search('type = Bug AND priority = High');
const items = await bugs.toArray();
items.forEach(bug => {
console.log(`${bug.key}: ${bug.summary} [${bug.status}]`);
});
return `Found ${items.length} high-priority bugs`;
Example: Bulk Update Issues
// Move all "To Do" issues in a project to "In Progress"
const results = WorkItems.search('project = MYPROJ AND status = "To Do"');
let count = 0;
await results.forEach(async (issue) => {
await issue.transition('In Progress');
count++;
});
return `Transitioned ${count} issues to In Progress`;
Example: Create Multiple Issues
const titles = ['Set up CI pipeline', 'Write unit tests', 'Deploy to staging'];
for (const title of titles) {
await WorkItems.create('MYPROJ', 'Task', b => {
b.setSummary(title);
b.setPriority('Medium');
});
console.log(`Created: ${title}`);
}
Execution Limits
| Limit | Value |
|---|---|
| Maximum script size | 100 KB |
| Execution timeout | 25 seconds |
| Console output | Captured and displayed after execution |
If a script exceeds the timeout, it is terminated and an error is shown. For long-running operations, consider breaking the work into smaller batches or using a Scheduled Job.
Tips
- Use
returnat the end of your script to display a final result in the output panel console.log()statements appear in the output in order of execution- Errors are caught and displayed with stack traces — you don't need to wrap everything in try/catch
- The console executes scripts as the app (service account), so it has access to all projects