Hooks / ScriptRunner alternatives / Migration guide

Migrating from ScriptRunner for Jira Cloud: Groovy to TypeScript

Last updated 19/11/2026.

The short version: list your ScriptRunner scripts and sort them into three groups: moves to Hooks, moves to Jira Automation, and stays on ScriptRunner (Behaviours and workflow functions). Convert the first group one script at a time. Most Cloud scripts are a few REST calls, so they translate almost line for line. Rehearse each one with dry run, and switch it on in Hooks as you switch the original off. Both apps can run on the same site the whole time.

1. Map each ScriptRunner feature

ScriptRunner for Jira CloudIn HooksNotes
Script ListenersListeners: onCreate, onUpdate, onDelete, onAssign, onComment, onWorklog, onLink, onAttachment, onVersionThe event is in context.event. Scope by project, work item type or changed field with pickers instead of code.
Scheduled JobsScheduled hooks (onSchedule)Plain-words builder or cron (UTC), checked every 5 minutes
Script ConsoleConsoleAdds dry run and "Run as me". Runs have about 25 seconds, and bigger jobs go to bulk jobs.
Console loops over many work itemsBulk jobsOne script per work item, in the background, up to 50,000 items, no timeout
Enhanced Search: issueFunction in linkedIssuesOf(...) etc.Built-in JQL functions: issue in linkedIssuesOf(...)15 shared names. The Migrate from ScriptRunner tab converts your saved filters automatically, including link-type arguments.
Other Enhanced Search functionsissue in hooked("name")A script returns a JQL fragment or up to 1,000 work item keys
Enhanced Search saved filtersOrdinary Jira saved filtersBoards, dashboards and subscriptions use them directly, and results usually catch up within about a minute of a change. The Migrate tab converts them in place, so existing board and dashboard links keep working.
Scripted FieldsScripted field (Hooks)One read-only text field (255 characters), searchable in JQL
BehavioursNot availableKeep on ScriptRunner
Workflow post-functions, conditions, validatorsNot availableKeep on ScriptRunner, or use JMWE. An onUpdate hook scoped to Status covers many post-functions, but it runs just after the transition.
Script variables / script parametersConstants at the top of the scriptEvery save is versioned, so changing a constant can be rolled back

2. Learn the Hooks API in one table

Cloud ScriptRunner scripts mostly use get, post and put against /rest/api/2 or /rest/api/3. In Hooks the common calls have typed helpers, and everything else goes through jira.request:

Groovy in ScriptRunner CloudHooks
get("/rest/api/2/issue/${key}")await jira.getIssue(key, "summary,status")
get("/rest/api/2/search").queryString("jql", q)await jira.search(q, 50)
a paging loop over a searchawait jira.forEachIssue(q, async (i) => { ... })
post(".../comment").body([body: text])await jira.addComment(key, text)
put("/rest/api/2/issue/${key}").body([fields: [...]])await jira.updateIssue(key, { ... })
post(".../transitions").body([transition: [id: id]])await jira.transition(key, id)
anything elseawait jira.request("PUT", path, body)
logger.info(...)console.log(...), stored with the run

3. Six conversions

Each example shows a typical ScriptRunner for Jira Cloud script and its Hooks equivalent. The Hooks versions are plain JavaScript, which is also valid TypeScript, so you can paste them straight into the Console.

Example 1: comment when a work item is created (Script Listener)

ScriptRunner: listener on Issue Created

def result = post("/rest/api/2/issue/${issue.key}/comment")
    .header("Content-Type", "application/json")
    .body([body: "Thanks - we'll triage this within one business day."])
    .asString()
assert result.status == 201

Hooks: kind onCreate, scoped to project SUP

const key = context.event.issue.key;
await jira.addComment(key,
  "Thanks - we'll triage this within one business day.");
return { commented: key };

The project restriction moves out of code and into the hook's Only run for picker. A failed comment shows up in Run history with its error, rather than as a failed assertion that's easy to miss.

Example 2: close sub-tasks when the parent is done (listener on update)

ScriptRunner: listener on Issue Updated

def change = changelog?.items?.find { it.field == "status" }
if (change?.toString != "Done") return

issue.fields.subtasks.each { st ->
    def ts = get("/rest/api/2/issue/${st.key}/transitions")
        .asObject(Map).body.transitions
    def done = ts.find { it.to.name == "Done" }
    if (done) {
        post("/rest/api/2/issue/${st.key}/transitions")
            .header("Content-Type", "application/json")
            .body([transition: [id: done.id]])
            .asString()
    }
}

Hooks: kind onUpdate, changed field Status

const change = context.event.changelog?.items
  ?.find((i) => i.field === "status");
if (change?.toString !== "Done") return "not done";

const parent = await jira.getIssue(
  context.event.issue.key, "subtasks");
const closed = [];
for (const st of parent.fields.subtasks ?? []) {
  const { transitions } = await jira.request("GET",
    `/rest/api/3/issue/${st.key}/transitions`);
  const done = transitions.find((t) => t.to.name === "Done");
  if (done) { await jira.transition(st.key, done.id); closed.push(st.key); }
}
return { closed };

Scope the hook to the Status changed field so it only wakes up on status changes. This is one of the 11 starter examples in the Console.

Example 3: label stale tickets every weekday (Scheduled Job)

ScriptRunner: Scheduled Job, 0 0 8 ? * MON-FRI

def jql = "project = SUP AND status = 'Waiting for support' AND updated <= -3d"
def found = get("/rest/api/2/search")
    .queryString("jql", jql)
    .queryString("fields", "summary")
    .asObject(Map).body

found.issues.each { i ->
    put("/rest/api/2/issue/${i.key}")
        .header("Content-Type", "application/json")
        .body([update: [labels: [[add: "stale"]]]])
        .asString()
}

Hooks: kind onSchedule, "every weekday at 08:00"

const jql = 'project = SUP AND status = "Waiting for support" AND updated <= -3d';
const marked = [];
await jira.forEachIssue(jql, async (i) => {
  await jira.request("PUT", `/rest/api/3/issue/${i.key}`,
    { update: { labels: [{ add: "stale" }] } });
  marked.push(i.key);
});
return { marked };

ScriptRunner uses Quartz cron with seconds. In Hooks you pick "Every week on Mon-Fri at 08:00" in the builder, or type standard 5-field cron (0 8 * * 1-5). Times are UTC, and the builder previews the next runs in your local time. The search pages for you, so one run labels every match, not just the first page.

Example 4: a bulk fix over thousands of work items (Script Console)

ScriptRunner: Script Console with a paging loop

def jql = "project = OPS AND labels = legacy"
def startAt = 0
while (true) {
    def page = get("/rest/api/2/search")
        .queryString("jql", jql)
        .queryString("startAt", startAt)
        .queryString("fields", "labels")
        .asObject(Map).body
    page.issues.each { i ->
        put("/rest/api/2/issue/${i.key}")
            .header("Content-Type", "application/json")
            .body([update: [labels: [[remove: "legacy"], [add: "archived"]]]])
            .asString()
    }
    startAt += page.issues.size()
    if (page.issues.isEmpty() || startAt >= page.total) break
}

Hooks: bulk job, JQL project = OPS AND labels = legacy

// Runs once per matching work item, in the background.
await jira.request("PUT",
  `/rest/api/3/issue/${context.issue.key}`,
  { update: { labels: [{ remove: "legacy" }, { add: "archived" }] } });
return context.issue.key;

A long console loop can hit the run time limit halfway through and leave you not knowing where it stopped. A Hooks bulk job takes the JQL separately and handles paging, progress, error samples and cancel for you. Run it once with Dry run on to see every change it would make, then run it for real. Pages can be retried after a crash, so write bulk scripts that are safe to run twice. Removing one label and adding another, as here, is safe.

Example 5: a calculated field (Scripted Field)

ScriptRunner: Scripted Field (Number)

def created = Date.parse(
    "yyyy-MM-dd'T'HH:mm:ss.SSSZ", issue.fields.created)
def days = (new Date().time - created.time) / 86_400_000
return days.intValue()

Hooks: kind onField

const wi = await jira.getIssue(context.issue.id, "created");
const ms = Date.now() - new Date(wi.fields.created).getTime();
return Math.floor(ms / 86400000) + " days old";

Add Scripted field (Hooks) to your screens and it computes when a work item is viewed. The value is stored, so you can search on it in JQL. Hooks has one scripted field, holding text up to 255 characters. If you have several ScriptRunner scripted fields, move the one that matters most and keep the rest where they are.

Example 6: Enhanced Search JQL in a saved filter

ScriptRunner Enhanced Search

issueFunction in subtasksOf("project = WEB AND fixVersion = 4.2")
  AND status != Done

issueFunction in linkedIssuesOf("key = INC-12", "is blocked by")

Hooks: built-in function, then a hooked() script

issue in subtasksOf("project = WEB AND fixVersion = 4.2")
  AND status != Done

issue in hooked("blockers-of-inc-12")
// kind onJql, name blockers-of-inc-12
// Returns the work items that block INC-12.
const wi = await jira.getIssue("INC-12", "issuelinks");
return (wi.fields.issuelinks ?? [])
  .filter((l) => l.type.inward === "is blocked by" && l.inwardIssue)
  .map((l) => l.inwardIssue.key);

The first query only needs issueFunction changed to issue. The Migrate from ScriptRunner tab does this for you across every Enhanced Search filter on your site, and the link-type argument in the second is converted too. The four-line hooked() script is shown for logic the built-ins can't express. Save either query as a normal Jira filter and use it on boards and dashboards. If the script ever fails, the filter returns no matches instead of an error, and the failure is recorded in Run history.

4. Switch over without downtime

  1. Install Hooks alongside ScriptRunner. The two apps don't interfere.
  2. Move one script at a time. Start with the noisiest or most fragile listener, because that is where run history pays off first.
  3. Rehearse it. In the Console, turn on Dry run and simulate the event. Every write is logged instead of sent.
  4. Save the hook disabled. Turn off "Enable this hook on save", then turn the hook on and the ScriptRunner original off together, so a work item is never processed twice.
  5. Watch Run history for a few days. If something is wrong, roll back to an earlier version in one click, or switch the ScriptRunner original back on.
  6. Move saved filters last. Use the Migrate from ScriptRunner tab: it verifies each filter against ScriptRunner's results and migrates it in place, so board and dashboard links keep working. Restore undoes any filter.
  7. Keep ScriptRunner for what doesn't move. Once only Behaviours or workflow functions are left, decide whether they justify the licence, or whether JMWE or Jira Automation can take them.

Things that catch people out

The full API and limits are in the Hooks documentation.

Install Hooks next to ScriptRunner → Hooks vs ScriptRunner