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
Have a standard task (like a Maven 3 task) configured as part of your job.
Add a new task, ScriptRunner Scriptable Task.
Click the Scriptable Task heading because there is only one type of task in this category.
Click the Copy from Other Task highlighted link instead of writing the code for the task from scratch.
Click the dropdown that shows you all tasks in all jobs, and then select the task to generate the code.
Click OK.
Result: The generated code for the task appears in the Code Editor.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 default:
Multiple Tasks
You can also create/execute multiple tasks rather than a simple task. The following trivial example will execute two script tasks: