This page describes how to configure a Bamboo task to use a script executable. You can use Bash on Linux, and batch files on Windows.
Related pages:
To configure a script task:
- Navigate to the Tasks configuration tab for the job (this will be the default job if creating a new plan).
- Click the name of the desired script task, or click Add Task and then Script if creating a new task.
Complete the following settings:
Script configuration Task Description A description of the task, which is displayed in Bamboo. Script location 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.
Argument Specify an argument to pass to the script. Arguments that contain spaces must be quoted. You can include variables (see Bamboo variables).
If required, specify environment variables and working directory settings:
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 Bamboo 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. Run as Powershell script (Optional, Windows only) Check the 'Run as Powershell script' checkbox to run the script with Powershell instead of cmd.exe which interprets .bat files. The inline editor supports Powershell syntax. - Click Save.

67 Comments
Anonymous
Aug 21, 2010Can a script be a python code?
Anonymous
Aug 24, 2012Only if you use the hacky method of turning a shell script into a python script using heredoc.
Anonymous
Jan 18, 2013How do I reference my Bamboo variables in bash? It doesn't like the dot in bamboo.variable
Anonymous
Jan 22, 2013Same problem here.
James Dumay
Jan 23, 2013Bamboo variables are exported as bash shell variables. The name is converted to capital casing and all full-stops are converted to underscores. For example, the variable bamboo.my.variable is $BAMBOO_MY_VARIABLE in bash.
dustin_barnes
Jan 17, 2014No, they're not.
... running command line:
/bin/sh /var/tmp/env.sh
... in: /opt/atlassian/bamboo/current/xml-data/build-dir/XXXX
The env.sh script is a simple "env" command – because the docs say that the variables are only there for file-type scripts.
This seems to be a huge bug with 5.3.
Anonymous
Feb 13, 2013How can I let a script (exit code?) tell bamboo to fail the build?
James Dumay [Atlassian]
Feb 13, 2013Any non-zero exit code will cause the Script task to fail.
Anonymous
Mar 07, 2013I can't seem to get any of the bamboo run-time variables to work with my shell script. I'm specifically trying to use bamboo.build.working.directory. Trying to just echo the value from the script (bash script on centos linux):
echo ${bamboo_build_working_directory}
echo ${BAMBOO_BUILD_WORKING_DIRECTORY}
echo $BAMBOO_BUILD_WORKING_DIRECTORY
all of these return blank lines.
Karel Bemelmans
Dec 20, 2013It's just the same: ${bamboo.build.working.directory}
If you want to see a list of all variables available during a script's runtime, just output 'env' and you will get a list.
dustin_barnes
Jan 17, 2014You're not alone. I think that feature is just broken on any modern version of Bamboo. It's late Jan 2014, and I'm running into the same problem, but Atlassian seems very disinterested in fixing it. Their roadmaps for fixes aren't even prioritizing it, but don't worry, AWS regions in Asia are getting top support! </sarcasm>
Anonymous
Jan 22, 2014I'm having the same problem. Do you know if there's a bug submitted? I can't find it.
Anonymous
Mar 07, 2013I also tried setting up a plan variable that points to ${bamboo.build.working.directory} and then using that plan variable in the shell script. It returns the string ${bamboo.build.working.directory}.
Anonymous
Mar 19, 2013> How can I let a script tell bamboo to fail the build?
return a none-zero
> then how could i set a custom build failure info?
Anonymous
Apr 25, 2013This is weird. For a Windows agent I defined CScript as a custom executable so that I can run a VBScript using Windows Scripting Host. I have a few named arguments that I quoted to pass to CScript, e.g., /sign /dryrun.
Bamboo insists on changing the forward slashes to backslashes. How is that useful? My script won't run because it doesn't understand the arguments being fed to it.
Ben Kershner
Jun 05, 2013Is there anyway to force a TTY on the script? I'm trying to use sudo to install a couple of packages (e.g. "sudo apt-get install foo").
Kelly Schoenhofen
Jun 21, 2013I'm stuck on a similar problem. To get past the issue you're having (or had, as this is 16 days later) I ended up turning off the password prompt for sudo; this seemed preferable to encoding a password into a build.
Edit your sudoers file and change the bottom/admin line to the following, then reboot:
It doesn't give out sudo, it just tells the system not to prompt for your password if you're on the sudoers list.
Sorin Sbarnea
Jul 03, 2013Is my impression that this page states that Bamboo will run inline-scripts with bash on Unix and with cmd.exe on Windows and there is no way to change this for inline-scripts? Jenkins allows you to specify the interpreter using the shebang line, allowing you to run the scripts with almost anything.
Kelly Schoenhofen
Jul 09, 2013Technically, Bamboo uses a non-interative /bin/sh, not bash, unless you add bash via a custom builder (i.e. /bin/bash). I've had very mixed results with that, and have stuck with living with the non-interactive /bin/sh and worked around my issues there.
-Kelly
PS - Atlassian, your captcha system is bugged. I know I'm typing in the right word on the first try, but it frequently insists I'm not. Do not tell me I'm typing it in wrong. Your system is wrong.
Karel Bemelmans
Dec 20, 2013You could also just make your own script, have it somewhere available on the build server and then make it available as a script on build server. You then chose "Command" instead of "Script" for a task and just pass in same arguments to your script from Bamboo.
(I'm using Bamboo Ondemand, no idea if the downloaded version also has this feature)
Anonymous
Jul 09, 2013What's the advantage of using a script file as described here than using a .bat file registered as executable?
Julian
Jul 09, 2013I've got the same question...
Kelly Schoenhofen
Jul 09, 2013Well, inline scripts are handy because you can expose the build them to users (and thus let them control some of the build/deployment process) without giving them write access to your source code repository (if you are storing your build scripts in source control) or the build server itself (if you're relying on scripts/batch files in the system path).
Conversely, if you control access to the inline script in Bamboo, you can hide the server-level stuff (like hard-coded credentials) from source control where many people perhaps have at least read access, and keep source control for source, not for deployment batch files used by DevOps/et al.
-Kelly
Anonymous
Jul 18, 2013Hi,
Can the script be a PERL script?
Thanks,
Kelly Schoenhofen
Jul 18, 2013It can be anything you want, as long as you recognize it will be executed by /bin/sh. (on a linux box, for instance). Adjust your bits accordingly; for instance, as an inline script you could do this (I assume):
python path/to/the/script.py
Or if you have #!/usr/bin/python at the top of your script, and it's executable, you could just do an inline script like:
./path/to/the/script.py
If you're wondering if you can paste a python script into the inline script editor and get Bamboo to use python to run it - I don't think their custom builder (such as specifying /bin/bash, or /usr/bin/python) allows inline scripting yet, so that's a no. That would be a nice feature to have though.
Sorin Sbarnea
Jul 18, 2013No that's impossible with Bamboo and one of the reasons why we are still very happy to use jenkins, as this allows you to provide any inline script, being able to take case of the shebang line across multiple platforms, including Windows.
Bamboo doesn't,... I was surprised to dicover this while evaluating the product. Clearly a basic requirement for any build system, not a weird one... still misssing.
James Dumay
Jul 19, 2013If we changed it to honour the #! at the beginning of the script, would this work for you?
BAM-13383 - Getting issue details... STATUS
Kelly Schoenhofen
Jul 19, 2013That change alone would be worth a major release of Bamboo.
Sorin Sbarnea
Jul 19, 2013Correct bug BAM-13383 - Getting issue details... STATUS ...the previous one is just a duplicate of this
Kelly Schoenhofen
Jul 18, 2013This shouldn't be a "Bamboo vs Jenkins" thread - they are different products, with different audiences. Bamboo is a build & deployment orchestrator & integrator. Jenkins is a development tool. While they share many features and uses on a venn diagram, they aren't the same circle.
If you're struggling with Bamboo vs Jenkins, then maybe you need to understand your needs a little better; it shouldn't be a fight and you should use the product that fits your needs best, not spend your time & energy forcing a round peg into a square hole.
-Kelly
Sorin Sbarnea
Jul 18, 2013While I agree with you that this should not became such a thread, I should note that both of them are same kind of products, with and almost total overlap, and the proper term would be "continuous integration server". Usually I don't like to quote wikipedia, but you can check. And the living proof is that Bamboo is presented by Atlassian as a posible replacment for Jenkins, as they do provide an import tool inside the product, in fact the only kind of import that you can do.
James Dumay
Jul 19, 2013You are correct - we do position Bamboo as a replacement for Jenkins. We don't claim to do everything that Jenkins does, but we think there are a number of great areas (For example, Deployment projects, plan branches and JIRA integration) where we think Bamboo really shines.
As in all products, there are plenty of areas for improvement. If you have any suggestions or feature enhancement ideas, please file them here (I read all the new issues every day).
Sorin Sbarnea
Jul 19, 2013Here is the bug related to being able to run generic scripts (shebang support): BAM-13383 - Getting issue details... STATUS I invite others to add their comments or at least vote if they are about this missing feature.
James Dumay
Jul 19, 2013Thanks for quoting the right ticked. I closed the one I opened as a duplicate.
dustin_barnes
Jan 17, 2014James, you have seemed quite active here, but here's 2 issues where I'm seeing Bamboo fail me:
I'm just concerned that Bamboo was a bad purchase for our company, and as a consultant, I'll never be able to recommend it to clients. I'm just really confused as to the priorities of feature/bug fixes, because those two issues above seem like minimum viable features for a build server that is free, much less one that is paid.
Kelly Schoenhofen
Jan 17, 2014If your build system should also be your quality & metrics center, than you may want to look at Jenkins.
After trying to scale Jenkins up (and failing) I am glad Bamboo doesn't include tools like JaCoCo, JSCover, Sonar, etc. I would rather use Bamboo as our build & deployment orchestration server. Let the builds themselves do Coverity analysis, and keep the core build system out of it.
Yes, they include a junit xml parser as a nod to the ubiquity of unit tests failing a build; I consider it a starter block to get you going. If I really needed Bamboo to fail a build if code coverage dropped below 80% all automagically, I would look to the marketplace to supply the plugin. Bamboo's plugin marketplace is pretty thin right now; I think they need more installs to start growing the community. The progress they have made in the last 18 months on the product has been the right thing to do - stopping to write a FindBugz plugin wouldn't make the product more "enterprise" (which is what I'm looking for), it would just chase the Jenkins SKU which is covered quite well by Jenkins.
I also have issues with Bamboo:
Otherwise, I'm still happy with the stability, robustness and Bamboo's core functionality working so well.
dustin_barnes
Jan 17, 2014I appreciate your reply. Thanks!
As for code quality, I just want it tracked. I want a visual chart of how different things work. I think that's a perfectly reasonable thing to look for in a commercial CI system. We are on 5.3 here, and there isn't one single "reporting" plugin. It seems weird that they'd spend all this time writing a reporting infrastructure, but not actually use it for what seems to be the primary use case. I'd be very surprised if Atlassian themselves didn't use and track these metrics. Maybe they have another solution?
James Dumay
Jan 21, 2014We use other in house solutions for performance metrics and a few teams use Findbugs and JMeter plugins to track these metrics.
James Dumay
Jan 21, 2014Great feedback Kelly.
As of Bamboo 3.4, Bamboo automatically upgrades Remote Agents when the server version changes which saves you doing this yourself.
Kelly Schoenhofen
Jan 21, 2014James, if same-sex marriage was legal in Australia, I would fly there tonight. My wife would surely understand.
James Dumay
Jan 21, 2014Hahaha almost died when I read this.
You'd have to fight my actual same-sex partner for the privilege
James Dumay
Jan 21, 2014Hi Dustin,
Thanks for the feedback. Is BAM-14218 the ticket in question? We haven't seen any reports that points to this being broken, but ill have someone investigate.
I agree with you that we need to get better at supporting quality metrics.
Thanks
James
dustin_barnes
Jan 21, 2014Yep, that's the one. Thanks for taking a look at it. I see quite a few people saying that the bash environment variables just don't exist, and I took some steps to prove it.
I even spent a chunk of Friday learning the plugin stuff so I could write a quick plugin to spit that info out into a properties file so it could be consumed by the rest of the build process, but I'd prefer to not have to maintain that
.
James Dumay
Jan 21, 2014Its on the top of our backlog but it may not make it into 5.4 (due in approx. two weeks) as we are committed to the work in our last sprint.
saravanan subramanian
Jul 19, 2013Hi,
using the inline scripts - users are able to rename the files in bamboo_home? how can we prevent this from happening
James Dumay
Jul 20, 2013The only way to prevent this is to run remote agents on different user accounts on the same machine that do not have read or write access to the bamboo home.
Anonymous
Aug 18, 2013How can I get Bamboo to run a script on Win2k8r2 in 32 bit mode? I need it to remap the paths to Program files, etc just as a script run by the 32 bit version of cmd.exe on a 64 bit OS would.
Anonymous
Oct 10, 2013Add an executable task instead of the script task. pass in your powershell that way. Set it up in admin using 32 bit.
Aris Green
Nov 08, 2013I'm confused, from a script task that calls the OS's shell, be it cmd.exe on Windows or bash on Linux, just get that to call you Python, Groovy, Ruby, whatever the heck you want. I think you can get what you need with just that. Parameters can be based to the shell script via the command line and/or environment variables. Yeah, inline Python scripts might be nice, but you can just have the shell call that in a script. I guess with Windows, you can call a PowerShell script directly. I am new to Bamboo, what I would like to learn is how to have a shell script return values back to Bamboo for conditional logic. With Jenkins, the script can write out to a Java properties file and the values read by in via the EnvInject plugin.
ArmenA
Nov 08, 2013Hi Aris,
Bamboo doesn't have an embedded capability to play with the return values; all non-zero values are considered fail and 0 is success. If you want to have more control over the return values, please consider calling a script from a script file, catch the return value, and make sure that the initial one returns 0 if you want it to succeed.
Armen
Mehul Sanghvi
Nov 12, 2013I have a simple in-line script:
It gets to the last line, executes the command, and causes the agent to crash. I don't believe there is anything wrong with the script, is there ?
Mehul Sanghvi
Nov 12, 2013Got it wrong. The above lines of script do not cause a problem. What is causing the problem is the task that follows the above mentioned task. It is a script, in a file, not in-line, and it does not even make it to the first command in the script:
The output of the echo does not show up anywhere in the logs
Kelly Schoenhofen
Nov 12, 2013I have seen the same thing, and it's standard practice here to take out all #'d lines in inline scripts. I can usually get by with one but not two in a row.
It's irritating because there are times when I really would like some script documentation for the next person to see, or I need to comment out (via #) a chunk of lines temporarily in a inline script and I can't because of this limitation.
-Kelly Schoenhofen
Mehul Sanghvi
Nov 12, 2013Solved!
Turned out to be an errant ps/kill combination. The Bamboo agent process was being killed because it was not filtered out of the output from ps.
Mehul Sanghvi
Nov 15, 2013Why does Bamboo have to prefix all environment variables with "bamboo_" ? If I have a plan variable called FOO_BAR, I want it passed to the shell as an environment variable called FOO_BAR not bamboo_FOO_BAR. I now have to go through and edit about 117 files and change them to use bamboo_*. No other build system does that.
I can understand converting to upper case and replacing "." with "_", but actually adding a prefix that was not specified does not seem right at all. It causes vendor lock-in. If I at some later point want to switch to something else, I have to make changes to scripts that I should never have had to change in the first place.
Anonymous
Dec 11, 2013Hi,
We have a deployment script we run on our server that does the following:
Is it at all possible to implement this command with Bamboo so that we could see what the deployment will do exactly from the Bamboo interface and then give the go ahead?
Kelly Schoenhofen
Dec 11, 2013Bamboo runs its tasks in a non-interactive window, so on the face of it, no.
You could make some kludge where it could write the results to a DB and twiddle its electronic thumbs while you decide yay or nay, periodically checking for a yay (or nay).
Or, break this up into multiple stages and put an approval process in between the stages.
Anonymous
Dec 14, 2013Can my script leave behind environment variables for the next tasks?
Mehul Sanghvi
Dec 14, 2013Each script task will run in its own process space, so when the task ends, that process space is destroyed as are its child processes. When that happens, the environment of the process, and the script, is destroyed as well.
What you could do, is probably write out the environment, as one of the last things you do before the end of the task, to a file in some common location, that subsequent tasks can access, modify, etc. as needed.
Hope that helps.
Christian Marth
Dec 14, 2013I'm trying to use script to generate a variable which contains a git log, which i can acces as a variable in a subsequent task, the log contains multiple lines,
git log --no-merges --pretty=format:"* %s" ${bamboo.repository.previous.revision.number}..${bamboo.repository.revision.number}>changelog.txtI'm successfully able to write this out to a file but am having issues trying to access it in the inject variables plugin, is there a simpler way to do this by using the script to set a variable?
James Dumay
Dec 15, 2013I believe variables have a limit of 256 characters so this might not be the best approach.
Can you tell me a little bit more about what you are trying to achieve? What task do you want to pass it to?
Christian Marth
Dec 16, 2013I'm trying to pass it to hockeyapp as a Release Notes... I'm probably better writing this functionality in the Xcode plugin.
Ben Bailey
Dec 15, 2013Please help. I am running a .bat file using the onDemand version on Bamboo against a windows EC2 machine. The batch file is clearly being executed by the "bamboo" user. To run this batch file requires admin privileges. How can I run my batch file as an admin user automatically?
Am I being blocked by this bug? BAM-14097 - Getting issue details... STATUS
Mark Gillespie
Mar 04, 2014This REALLY needs to talk about exit values/return codes. I came here looking for this, and there is not a single mention of this, which for a build system is pretty fundamental.
NathanA
Mar 04, 2014Hi Mark,
This page is about how to configure your script to run. What sort of information about exit values/return codes are you after? Output format?
Let me know and I will see if this is a hole that needs plugging in our docs.
Cheers,
Nathan
Sylvain Gil
Apr 02, 2014Hi Nathan,
I came here wondering how the task success/status would be impacted by the exit code of the invoked script. In other words, what is the proper way to signal to the task that the script has executed properly or not.
Thanks,
Sylvain
Max Kalb
Apr 16, 2014i get