Wiki

Clone wiki

modplan / Home

It's easy to interact with the plugin using wget, curl or a HTTP client in your favourite scripting language. The examples shown here will use wget and curl.

List of REST API paths Script examples coming soon.

XML vs JSON

Note that like the rest of the Bamboo REST API, results can be returned in XML or JSON. The default is XML, for example:

$ wget http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/repository -O- -q 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <KVList><list>
    <pair>
      <key>filter.pattern.option</key>
      <value>none</value>
    </pair>

    <pair>
      <key>filter.pattern.regex</key>
      <value></value>
    </pair>

    <pair>
      <key>repository.common.cleanCheckout</key>
      <value>false</value>
    </pair>

   ... continues ...

Adding .json onto the URL:

$ wget http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/repository.json
{
    "list": [
        {
            "key": "filter.pattern.option", 
            "value": "none"
        }, 
        {
            "key": "filter.pattern.regex", 
            "value": ""
        }, 
        {
            "key": "repository.common.cleanCheckout", 
            "value": "false"
        }, 

    ... continues ...

All further examples will be in JSON as it's easier to read.

Listing repository configuration variables

The full repository configuration for a plan can be listed:

$ wget http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/repository.json 

This command assumes the Bamboo server is located at http://localhost:6990/bamboo and that we're interested in a plan with key PLAN1 in project TESTPROJ. The "Plan Summary" page for this plan will be found at: http://localhost:6990/bamboo/browse/TESTPROJ-PLAN1.

{
    "list": [
        {
            "key": "filter.pattern.option", 
            "value": "none"
        }, 
        {
            "key": "filter.pattern.regex", 
            "value": ""
        }, 
        {
            "key": "repository.common.cleanCheckout", 
            "value": "false"
        }, 
        {
            "key": "repository.common.cleanWorkingDirectory", 
            "value": "false"
        }, 
        {
            "key": "repository.common.quietPeriod.enabled", 
            "value": "false"
        }, 
        {
            "key": "repository.common.quietPeriod.period", 
            "value": "10"
        }, 
        {
            "key": "repository.common.quietPeriod.maxRetries", 
            "value": "5"
        }, 
        {
            "key": "repository.git.repositoryUrl", 
            "value": "https://bitbucket.org/carlglewis/modplan.git"
        }, 
        {
            "key": "repository.git.username", 
            "value": ""
        }, 
        {
            "key": "repository.git.password", 
            "value": ""
        }, 
        {
            "key": "repository.git.branch", 
            "value": ""
        }, 
        {
            "key": "repository.git.ssh.key", 
            "value": ""
        }, 
        {
            "key": "repository.git.ssh.passphrase", 
            "value": ""
        }, 
        {
            "key": "repository.git.authenticationType", 
            "value": "NONE"
        }, 
        {
            "key": "repository.git.useShallowClones", 
            "value": "true"
        }
    ]
}

Obviously the keys will different for different repository types.

Fetching specific repository variable

$ wget http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/repository/repository.git.repositoryUrl.json
{
    "key": "repository.git.repositoryUrl", 
    "value": "https://bitbucket.org/carlglewis/modplan.git"
}

Setting the value of a repository variable

Setting of values is done with HTTP POST requests. curl is very useful for doing this from the command line. A username and password is required because the Bamboo configuration is being changed.

$ curl -d true -H "Content-Type:text/plain"  'http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/repository/repository.common.cleanCheckout.json?os_authType=basic&os_username=user&os_password=password'

The response is not very interesting:

{
    "key": "default",
    "value": "Set key: repository.common.cleanCheckout to value: true"
}

The new value can then be read using a HTTP GET:

$ wget 'http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/repository/repository.common.cleanCheckout.json'
{
    "key": "repository.common.cleanCheckout",
    "value": "true"
}

Fetching whether a plan is enabled

$ wget http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/enabled.json 
{
    "key": "enabled", 
    "value": "true"
}

Enabling and disabling a plan

As with modifying the repository configuration, this is done with a HTTP POST. To disable a plan:

$ curl -d disable -H "Content-Type:text/plain"  'http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/enabled?os_authType=basic&os_username=user&os_password=password'

To enable the plan again use "enable" as the argument to -d:

$ curl -d enable -H "Content-Type:text/plain"  'http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/enabled?os_authType=basic&os_username=user&os_password=password'

Listing Jobs

It's possible to get a list of jobs in a plan.

$ wget http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/jobs.json

The response for a job with two Jobs in JSON format:

{
    "list": [
        "Test Project - Plan 1 - Default Job", 
        "Test Project - Plan 1 - Second Job"
    ]
}

The XML output for the same plan:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <JobList>
    <list>
      <name>Test Project - Plan 1 - Default Job</name>
      <name>Test Project - Plan 1 - Second Job</name>
    </list>
  </JobList>

Listing Stages

Very similar deal for listing stages:

$ wget http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/stages.json

Response for plan with single stage:

{
    "list": [
        "Default Stage"
    ]
}

Listing Tasks for a particular Job

A list of tasks for a particular job can be returned. In this example the first job for PLAN1 is selected:

$ wget http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/jobs/0/tasks.json

Response for a job with a single task. The user description of the task is returned:

{
    "list": [
        "Build Modplan plugin"
    ]
}

Listing the configuration of a Task

$ wget http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/jobs/0/tasks/0.json

Response:

{
    "list": [
        {
            "key": "argument", 
            "value": ""
        }, 
        {
            "key": "label", 
            "value": "Atlassian Plugin SDK packager"
        }, 
        {
            "key": "workingSubDirectory", 
            "value": ""
        }, 
        {
            "key": "environmentVariables", 
            "value": ""
        }
    ]
}

Reading a single Task parameter

$ wget http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/jobs/0/tasks/0/label.json

Response:

{
    "key": "value", 
    "value": "Atlassian Plugin SDK packager"
}

Writing a single Task parameter

This is again done with a POST request:

$ curl -d "new label" -H "Content-Type:text/plain"  'http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/jobs/0/tasks/0/label.json?os_authType=basic&os_username=user&os_password=password'

The response from the POST includes the new value of the parameter:

{
    "key": "value", 
    "value": "new label"
}

The new value can then be read with a GET:

$ wget http://localhost:6990/bamboo/rest/modplan/1.0/TESTPROJ-PLAN1/jobs/0/tasks/0/label.json

Response:

{
    "key": "value", 
    "value": "new label"
}

Updated