[Bamboo] How to cleanup maven local repository on agent?

I am happy to find out that Bamboo is capabile of isolation maven local repository on each agent. Now I have a problem how to clean up maven local repository on an agent (better, if there is a way to automatically wipe out after each build).

3 answers

1 accepted

0 vote

You can create a Final Task (as a regular script task) that will remove the repository, there's no automated way of doing it.

How do you access the variable of local repo in a script when it's isolated? The expression

$BAMBOO_HOME/.m2/AGENT-${agendid}/repository

from https://confluence.atlassian.com/display/BAMBOO/Configuring+repository+isolation+for+Maven+executables

Gives me an null-string for the ${agentid} part when used in script

Hi Bjarte,

just to be sure we're on the same ground: are you using ${agentid} or ${bamboo.agentId} (note the 'bamboo.' prefix and the uppercase 'I' in the 'Id' part) ? That said, I think the https://confluence.atlassian.com/display/BAMBOO/Configuring+repository+isolation+for+Maven+executables is outdated a bit - could you confirm whether the ${bamboo.agentId} substitution does work for you? If yes, I'd update the docs.

cheers!

${bamboo.agentID} works.

My inline script contains:

1. echo *** SCRIPT START ***

2. echo Repo: $BAMBOO_HOME/.m2/AGENT-$AGENTID/repository

Environmant variables settings on job:

AGENTID=${bamboo.agentId}

Build result.

20-Mar-2013 13:00:49 Running pre-build action: Maven Settings Prebuild Action
20-Mar-2013 13:00:49
Substituting variable: ${bamboo.agentId} with 20709377

20-Mar-2013 13:00:50 *** SCRIPT START ***

20-Mar-2013 13:00:50 Repo: /dnb/data/bamboo-home/.m2/AGENT-20709377/repository

using Bamboo 4.3.2 build 3402 -28 Nov 12

Thank you

You should look into Maven dependency plugin. It has a purge local repo goal. ( http://maven.apache.org/plugins/maven-dependency-plugin/purge-local-repository-mojo.html )

Put it in your maven pom of your project - and it will always delete all the dependencies your project depends on from local repo, and redownload them prior to building.

Hi guys.

This command

echo Repo: $BAMBOO_HOME/.m2/AGENT-${bamboo.agentId}/repository

shows me: 

Repo: /.m2/AGENT-32047106/repository

Env. variable AGENTID=${bamboo.agentId} is set correctly. I think correct output should be /home/bamboo/agent1-home/.m2/AGENT-32047106/repository

Where do I have issue? Thanks for some response.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 8 hours ago in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

103 views 4 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