Is there any way to manually clear a workspace in Bamboo?

One of our Bamboo plans is a continuous integration build of our product that just performs a simple incremental build (just as a developer would). We recently ran into a problem with our build tool where dependencies were not being tracked correctly which caused the incremental build to fail inappropriately. I fixed the issue but in order for that fix to activate we needed to do a clean build, not an incremental build. On the developer's machines this was easy, we just did clean build or ran 'git clean -xdf' to clear all temporary files, however I don't see any way to do that in Bamboo.

Is there any way to force some sort of cleanup in Bamboo manually to force a clean build? The optimal thing would be to be able to run 'git clean -xdf' to clear the repository of any temporary files, but other are on the table (e.g. wiping the workspace entirely). When we were using Jenkins we had the option to wipe the workspace in these situations.

In this case to fix the issue I RDP'd into the Bamboo machine and manually ran a git clean through a git bash window, however it would be more convenient if it were possible to do this through the web interface.

7 answers

1 accepted

As mentioned in my previous comment, this is the best I could come up with.

After playing around with this a bit more, one solution that I came up with is to define a Bamboo variable "ManualClean" that is 0 by default and add a Script that is passed ${bamboo.ManualClean} as a parameter and contains:


if "%1"=="1" git clean -xdf

If I want to perform a completely clean build I can "Run Customized..." and set that ManualClean parameter to 1. It works, but it'd be nice to not have to do this with every one of our builds.

2 votes
Colin Goudie Community Champion May 09, 2012

Under each task, in the Source Checkout task, you can select the option to 'force clean build' But then you need to run the build, then uncheck it again. Bit of a pain

I also thought there was a clear git cache somewhere but I can't seem to find it now in Bamboo 4 and also wasn't too sure what it did anyway ;)

I am looking for something similar. Because changes to .h files do not always trigger a rebuild correctly (C/C++) I had a system in place that would do a nightly clean rebuild before the deveopers arrived in the morning. This would ensure that the CI environment was providing the best information on the state of the repository firs thing in the morning.

What I would like to see is an option in the trigger section that would allow a scheduled build or manual build to momentarilty set the 'Force Clean Rebuild' flag. That way I could have the code checking builds rebuilding on top of what is there and the cron job could set the 'Force Clean Rebuild' flag when it runs overnight. It would/could also let someone run a manual customized build and set the flag for that execution trigger only.

I want to be able to set 'force clean build' as part of a customized manual run.

... or a scheduled run. It's what David Penney is talking about.

Why not create an Ant task that does the Git command and create a new job to run it? That way you can run it from Bamboo whenever you want.

I'm under the impression that each job gets its own copy of the git repository so a new job would be working from a different repo. Or am I not understanding some detail here? (I've never used Ant so I'm not sure if that's a factor here)

Hmm, it looks like you are correct. What you can do is go to the Bamboo machine, get the path of the first job, and then use that path with the git command in your Ant task. That way you can run it from a separate job whenever you want.

Here is an example Ant script:

<project name="yourname" default="git-clean" basedir=".">
    
    <target name="git-clean">
        <exec dir="/opt/bamboo-agent-home/xml-data/build-dir/PLAN-BUILD-JOB1" executable="git">
          <arg line="clean -xdf"/>
        </exec>
    </target>

</project>

Just replace the exec dir with where your build is located. I just recommend Ant because running command line tasks in Bamboo is so easy with it.

After playing around with this a bit more, one solution that I came up with is to define a Bamboo variable "ManualClean" that is 0 by default and add a Script that is passed ${bamboo.ManualClean} as a parameter and contains:


if "%1"=="1" git clean -xdf

If I want to perform a completely clean build I can "Run Customized..." and set that ManualClean parameter to 1. It works, but it'd be nice to not have to do this with every one of our builds.

I'd try what Colin suggests - tick "force clean build" checkbox in the relevant Source Checkout task(s).

As a SubVersion user of Bamboo, we don't have a simple command we can run on Windows workstations. (we have svn-clean on Linux) This is really a missing piece of the "Run custom..." dialog, where it gives the user the option to define an SVN version number. Why not also offer this checkbox?

The reality is, that in the proposed solution here, to hit that checkbox, you only need to do it once in a great while. Usually, you need not do a clean-build. But to do a clean build is really the workflow of a custom-build. It should just be a feature embedded in Bamboo. Coming soon to feature requests.

https://jira.atlassian.com/browse/BAM-15479

Suggest an answer

Log in or Join to answer
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,096 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot