JetBrains Space Help

Get and Set Job Run Number

To help you distinguish one job run from another, Automation assigns a number to every run. By default, the number is auto-incremented starting from 0 and is not unique (there can be two or more runs with the same number).

The run number is shown next to each job run on the project Jobs page.

Script execution number

Get the current job run number

Sometimes, you might need to get the current run number right from the automation script. For example, to generate a version number for the application you develop. You can do this either using the JB_SPACE_EXECUTION_NUMBER variable or the executionNumber() API function:

job("Example") { container(displayName = "Get job number with API", image = "amazoncorretto:17-alpine") { kotlinScript { api -> println("Build #" + api.executionNumber()) } } container(displayName = "Get job number with shell", image = "ubuntu:latest") { shellScript { content = """ echo ${'$'}JB_SPACE_EXECUTION_NUMBER """ } } }

Set the next run number

Setting the exact job run number might be helpful in some cases. For example, when you want to reset the run counter.

  1. Open the required project.

  2. On the project sidebar menu, choose Jobs.

  3. Open the required job by clicking its title.

  4. Click the menu icon in the top right corner and choose Change the next job number.

    Set execution number
  5. In the opened window, specify the desired value. The next job run will get the specified number.

Last modified: 15 December 2023