On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

This page describes how to configure a Bamboo task to run a script. The Script task is flexible enough to allow the possibility to use: the default shells on Linux (/bin/sh) or Windows (cmd.exe), a more modern shell on Windows (PowerShell), and an arbitrary shell in Linux by using the shebang on the first line of the script file. This can be controlled by the Interpreter field explained below.

To configure a script task:

  1. Go to the Tasks configuration tab for the job (this will be the default job if creating a new plan).
  2. Select the name of an existing script task, or select Add taskScript if creating a new task.
  3. In the Task description field, enter a description for the task that will appear in Bamboo.

  4. Check or clear Disable this task to selectively run the task.

  5. Optionally, select Add condition to task to make the task run only when a certain condition is met.

    You can find conditions on Atlassian Marketplace or implement your own.  

  6. From the Interpreter menu, select one of the available interpreters:

    • Shell (chooses the interpreter based on the first line of the script, typically using the shebang)
    • Windows PowerShell
    • /bin/sh or cmd.exe (uses the default shell of the operating system: sh for Linux, cmd.exe for Windows)
  7. From the Script location menu, select the location of the script file:

    • File — enter the location of the file in the Script file field. This can be either relative to the repository root of the plan, or absolute. You can include variables (see Bamboo variables).
    • Inline — enter the script in the Script body field.
  8. In the Script body field, enter or paste the code of your script using the syntax appropriate for the selected interpreted.

  9. In the Argument field, specify an argument to pass to the script.

    Arguments containing spaces must be quoted. You can include variables (see Bamboo variables).

  10. Optionally, in the Environment variables field, specify additional system environment variables that you want to pass to your build.

    • Separate multiple variables with spaces. Parameters values containing spaces must be quoted, for example:
      ANT_OPTS="-Xms200m -Xmx700m"
    • Existing environment variables are automatically available to the executable. You can also include Bamboo global or build-specific variables.
    • If the specified Bamboo variable is present during the task execution, the created environment variable will be set to its value. Declared variable values are passed to the task verbatim, which means that they will not get parsed by any other method and will be sent to the script as a literal string. Hence, no further variable expansion is performed. If you want to assign a script variable using the contents from another variable, do that internally within the script task. Learn how to load variables from within a script task

  11. Optionally, in the Working subdirectory field, specify an alternative subdirectory relative to the root directory of the job where Bamboo will run the executable.

    The root directory contains everything checked out from the job's configured source repository. If you leave this field blank, Bamboo will look for build files in the root directory. This option is useful if your task has a build script in a subdirectory and the executable needs to be run from within that subdirectory.

  12. Select Save.
Last modified on Jul 10, 2023

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.