Script Jobs in ScriptRunner allow you to script actions that will be run automatically at a specified time interval. We use crontab syntax to schedule tasks. You can access script jobs by clicking on:

Administration Menu > "Add-ons"

In the menu bar on the left hand side, under the SR heading you should see the "Script Jobs" option. If you click this it will take you to the Script Jobs menu.

ScriptJobMenu

Add a Custom Script Job

A custom script job allows you to write your own script that will be run at a timed interval. Let’s take a look at how we set one up!

Step One

Click the "Add New Item" button to reveal a list of the Script Jobs you can create.

Step Two

Click on "Custom scheduled job" from the list that appears.

ScriptJobAddNewItem

Step Three

Populate the form as appropriate to your use case.

ScriptJobAddCustomScriptJob
Field Description

User

The user that we want the script to run as.

Note

A reference that describes what you scheduled job is doing. This will be the text visible in the script job list.

Script

You can add either an inline script or reference to a script that exists in your "Script Root". This will be the action that you want to be done at a scheduled interval.

Cron Expression

You can add either an inline script or reference to a script that exists in your "Script Root". This will be the action that you want to be done at a scheduled interval.

There are built-in examples of cron expressions that you can put in by clicking the "Expand Examples" menu.

Step Four

Once the form is complete you can save the job by clicking the "Add" button.

The job WON’T be active until you click the "Add" button
You can test your script, at any time, by clicking the "Run now" button

Once the save is complete you should now see your scheduled job in the list of scheduled jobs in the main menu.

ScriptJobList

Edit a Scheduled Job

Sometimes you need to make a change to a script job that already exists.

  1. Click the actions menu for the job that you wish to edit.

  2. Click "edit" from the menu that is presented.

Delete a Scheduled Job

In some cases you may wish to remove jobs that you no longer require.

  1. Click the actions menu for the job that you wish to edit.

  2. Click "delete" from the menu that is presented.

For how-to questions please ask on Atlassian Answers where there is a very active community. Adaptavist staff are also likely to respond there.

Ask a question about ScriptRunner for JIRA, for for Bitbucket Server, or for Confluence.