Scriptable Tasks

Introduction

Scriptable tasks allow you to dynamically create and execute tasks with different parameters depending on build variables, files changed, etc, using the Bamboo Specs API.

For example, you might use different Maven goals depending on the branch or secure copy (scp) files to different hosts for different staging environments.

The generated task or tasks take the place of the scriptable task.

For example, you might use different Maven goals depending on the branch or secure copy (scp) files to different hosts for different staging environments.

The generated task or tasks take the place of the scripted task.

Usage

  1. Have a standard task (like a Maven 3 task) configured as part of your job.

  2. Add a new task, ScriptRunner Scriptable Task.

  3. Click the Scriptable Task heading because there is only one type of task in this category.

  4. Click the Copy from Other Task highlighted link instead of writing the code for the task from scratch.
    add scriptable task

  5. Click the dropdown that shows you all tasks in all jobs, and then select the task to generate the code.
    copy task code dlg

  6. Click OK.
    Result: The generated code for the task appears in the Code Editor.
    copy task code complete

  7. Now you can add conditional logic to change the parameters as required. You can also paste the code into a file under your script root and use theFiletab to point to the .groovy file.
    Here’s a full example that adds the deploy tasks if the branch is master:

    Action required

    Unauthenticated access to this resource is not allowed. Please login to Confluence first.


Multiple Tasks

You can also create/execute multiple tasks rather than a simple task. The following trivial example will execute two script tasks:

Action required

Unauthenticated access to this resource is not allowed. Please login to Confluence first.

On this page