Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Ian Bond May 9, 2012

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.

8 answers

1 accepted

0 votes
Answer accepted
Ian Bond February 10, 2013

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 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 ;)

1 vote
Krystian Brazulewicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 18, 2019

On demand cleaning of working directory can be achieved in the following way:

- add "clean.run" variable to your plan and set it to "false"

- add "Clean working directory" task as the first task in your job

- tick "Conditional task" and configure it so "clean.run" set to "true" will trigger task execution

- use "Run customised" to run your plan and override "clean.run" variable to true

1 vote
David Penney February 4, 2013

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.

benson margulies January 6, 2014

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

Tyler Mace January 30, 2014

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

0 votes
Tyler Mace January 9, 2015

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

0 votes
PiotrA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 2012

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

0 votes
Ian Bond May 9, 2012

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.

0 votes
Keith Miller May 9, 2012
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.
Ian Bond May 9, 2012

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)

Keith Miller May 9, 2012

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events