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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,858
Community Members
 
Community Events
176
Community Groups

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.

8 answers

1 accepted

0 votes
Answer 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

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

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

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.

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 May 09, 2012

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

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.

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.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events