Skip to end of metadata
Go to start of metadata

This page describes how to configure a Bamboo task that uses a command (e.g. Bash) executable.

See  Configuring a builder task for an overview of Bamboo builder tasks.

To configure a command task:

  1. Navigate to the Tasks configuration tab for the job (this will be the default job if creating a new plan).
  2. Click the name of an existing Command task, or click Add Task and then Command to create a new task.
  3. Complete the following settings:
     

    Task DescriptionA description of the task, which is displayed in Bamboo.
    DIsable this taskCheck, or clear, to selectively run this task.
    Executable

    The command executable that is available to perform the task (e.g. Bash). The executable that you select will become one of the task's (and so, the job's) requirements.

    You can add other executables, if required.
    Argument
    (Optional) The relevant argument to pass to the command. Note that arguments which contain spaces must be quoted. You can include variables (see Bamboo variables).
    Environment Variables(Optional)  Additional system environment variables that you want to pass to your build. Note that existing environment variables are automatically available to the executable. You can also include Bamboo global or build-specific variables (see Using global, plan or build-specific variables).
    Multiple variables should be separated with spaces. Parameters with spaces must be quoted (e.g ANT_OPTS="-Xms200m -Xmx700m").
    Working Sub Directory(Optional)  An alternative subdirectory, relative to the job's root directory, 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.
  4. Click Save.

11 Comments

  1. Anonymous

    Is there any way of passing commands with quotes, without Bamboo sticking newlines in there?  e.g. I want to run "cmake -G "Unix Makefiles" ../folder" (note that the quotes around "Unix Makefiles" need to stay there)

  2. Anonymous

    I have the same problem.  It causes my task to fail because the command I am trying to execute requires the arguments, but they are on another line.  It somehow interpolates from the custom Executable and Argument fields into this

     \n/usr/local/bin/build_perl_for_bamboo\n -b 8\n

    Full log line entry:

    22-Jan-2013 11:26:24	Beginning to execute external process for build 'My Proj - subproj - subsub - main - Default Job'\n ... running command line: \n/usr/local/bin/build_perl_for_bamboo\n -b 8\n ... in: /opt/atlassian-bamboo-agent/xml-data/build-dir/MYPROJ-MAIN-JOB1\n
  3. Can a custom command executable produce test results?  It seems like this capability was available in past releases (Custom Command Executable), but I've been unable to figure out where to specify this.

    I am trying to use the Gradle wrapper to build and test our project.  My plan configuration consists of a single stage, with a default job.  The tasks of the job are "source code checkout" and "command", where the command is "./gradlew check".  If tests fail, the build fails but test results are not reported.  There's no place that I can find to specify that "this build produces test results."

    Thanks!

    1. Would using a JUnit Parser task to the Job after your command executable task not work for you?

      1. Anonymous

        I had originally tried to do this but was confused with the quarantine / unleash process.  I would quarantine a failing test, run the custom executable, the test would fail, and then the JUnit Parser task would run.  The output from the parser task indicated first that it failed, then that it was changing its failure status to success since all failing tests were quarantined.  But the overall build would still fail.

        It took me a while to figure out, but the custom command was exiting with a non-zero status, then the parser task was running and exiting successfully.  I had to set the gradle test task to "not break the build" when the verifications failed.  (http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test:ignoreFailures)

  4. I need to write a very simple command: /usr/bin/unzip

    Some of the files in my repository are checked in as zipped (several reasons nonnegotiable -they must remain zipped).

    I need to unzip them, but the command tells me that it can't find the files.

    Obviously, I am relating from the wrong working directory.

    It was my assumption (ASS out of U and ME) that the working directory was the job root directory, which I thought was one level down from the root directory specified on the (remote) agent's config.

    That one down would be the job dir.

    So, if the root was set to /autobuild , and the job dir was /autobuild/JOB-Daily-1 , I would assume the latter (/autobuild/JOB-Daily-1) would be the base for a relative path for the working directory and input for the executable.

    Can someone clue me in on my mistake?

    Thanks!

  5. Anonymous

    Trying to execute command

    /bin/bash etc/stage-deploy.sh

    but it failes, no explanation. From command line where the project is checked out it works perfectly!

  6. Anonymous

    I have the following issue:

    I need to run a command that launches an external application. But I need the build to keep going instead of waiting for the application to "finish". Is this possible? I've tried with Script and Executable and both wait for the external app to close. I even tried placing the command inside a bat file and calling this bat from Script but still it waits on the launched app to finish.

     

    Is there any way to accomplish what I described above?

    Thanks.

  7. Have you tried to adapt your script so that it starts the external application as a background task?

  8. Anonymous

    Hi Nathan,

     

    Thank you for your reply. Yes I've started the app using start "" /B <exe> <args>.

    Also tried without the /B, tried inline script, file script (from bat), even tried adding the Executable as a capability.

    But the result is always the same, the build stops at the step where it opens the application and doesn't continue until I go to the agent and close the application (which I can't do since I need it running during the build).

     

    Any ideas?

    Thanks.

    1. Which version of Bamboo are you using? In the latest Bamboo versions there is a checkbox in the Advanced Options section of Script task configuration page (for PowerShell scripts); try to check that and see if that helps.

      Also, I found these issues - BAM-11488 - Starting a command in the background Open , BAM-11887 - Launching Tasks in the Background from Bamboo fails Open . If you are still facing problems, please create a support ticket on https://support.atlassian.com.

      Armen