Getting Started

Features

Configuration

What is it?

CQL Jobs allows you to run code at specific times of day/week/month on an specific interval.

CQL Jobs differs from Script Jobs as it allows you to run your code against a specific set of search CQL results, this will be typically pages.

Find out more about Script Jobs, here. Script Jobs

Why use it?

Like Script Jobs, CQL Jobs allows you to automate Confluence, saving a huge amount of time and ensuring your instance is well maintained.

How to use it?

Table View
  • Select the CQL Jobs tab in the ScriptRunner menu

  • Select the Add CQL Script Job option

  • Provide a name for your CQL job

  • Select if you want to run this task as yourself or another user

    • For example you may wish to have a task run as a user named Confluence Admin, so that that changes can be easily tracked

  • Select the schedule that you want this script to run

    • The schedule editor dialog lets you choose between running your script on several days during the week (e.g. Monday, Wednesday, Friday), or running your script on particular days of the month (e.g. the last day of the month, the 2nd Tuesday of the month)

    • Additionally you can select an hour interval during which your script will be run

  • Add your CQL query

    • To find out more about CQL, take a look at Atlassian’s documentation, here.

Example - You could target specific content that was mislabeled with a CQL query like "space = development and label = requirements". You could then write a script that will transform all of those labels to 'product requirements'

  • Add your script

  • Select Save

  • You can also elect to run the script immediately

The minimum interval between code executions is 1 hour. The scheduler is triggered every hour and gathers all the tasks to be executed within that hour. The task executions are queued and workers will consume them in no predefined order. That means that the execution time of the task can not be guaranteed to be the same every hour. As an example: if you configure a job to be run every hour, it might be run at 01:02 and then 02:24 and then 03:00 and then at 04:46 etc depending on how busy our systems are.

Each defined job must have a CQL query that will be run in order to find the content that you wish to modify. The code you provide as part of the job configuration will be run against each piece of content individually, and in parallel. Each content will be injected into your code as part of the Script Context.

The maximum amount of content you can modify in any execution of an Escalation Service job is 50.

In other words, we limit the amount of content returned by each CQL query to 50 items.

The schedule editor dialog lets you choose between running your script on several days during the week (e.g. Monday, Wednesday, Friday), or running your script on particular days of the month (e.g. the last day of the month, the 2nd Tuesday of the month). Additionally you can select an hour interval during which your script will be run.