Heads up! ScriptRunner for Bamboo documentation has moved to https://docs.adaptavist.com/sr4bam. Adaptavist will keep this site up for a bit, but no future updates to documentation will be published here. ScriptRunner 6.20.0 will be the last release to link to scriptrunner.adaptavist.com for in-app help.

The Script Console is the place for running one-off ad hoc scripts, learning, and experimenting with the Bamboo API.

You can enter your script directly in the browser or click the File tab to type the file path. The file can be a fully qualified pathname to a .groovy file accessible to the server. If you provide a relative pathname, the file is resolved relative to your script roots.

Read more about script roots and script plugins.

Samples

Take one of these code samples, and use it as a starting point for your own situation.

List all build plans

For example, return all the names of all the build plans:

import com.atlassian.bamboo.plan.PlanManager
import com.atlassian.sal.api.component.ComponentLocator

def planMgr = ComponentLocator.getComponent(PlanManager)

def plans = planMgr.getAllPlansUnrestricted()

def output = ""
plans.each {
    output += "${it.name}</br>"
}

output

List the status of all build jobs

For example, return all the names of all the build jobs:

import com.atlassian.bamboo.plan.PlanManager
import com.atlassian.sal.api.component.ComponentLocator

def planMgr = ComponentLocator.getComponent(PlanManager)

def plans = planMgr.getAllPlansUnrestricted()

def output = ""
plans.each {
    output += "<hr>"
    it.getAllJobs().each { job ->
        output += "${job.name} = ${job.getCurrentStatus()}</br>"
    }
    output += "<hr>"
}
output

Have questions? Visit the Atlassian Community to connect, share, and learn with other Atlassian users and experts, including Adaptavist staff.

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

Want to learn more? Check out courses on Adaptavist Learn, an online platform to onboard and train new users for Atlassian solutions.