5
votes

I am using Bamboo and have two branches: branch1 and branch2 as well as master.

When I build master the resulting artefact is deployed to a nexus repository as expected. However, when I build any of the branches they too get deployed to nexus.

Ideally what I want to happen is that only master is deployed to nexus.

Since both master and the branches use the same stage/job how would you configure this?

3

3 Answers

5
votes

In the end we settled on a solution which involved using branch variables. Using these we could then insert a value as a maven target i.e. mvn clean ${bamboo.variableName}. By default the variable had the value install but the master branch in Bamboo would override the variable and set it to deploy. This way all branches will just build and test whereas master would build, test and deploy.

3
votes

You should be able to select which branch is deployed when setting up an automatic deployment, documented here - https://confluence.atlassian.com/display/BAMBOO/Deployments+from+branches#Deploymentsfrombranches-Automatedbranchdeployment

2
votes

The solution that worked best for me was to use a script to decide what to do. So, instead of a maven task, I created script task and made it decide which command to run based on the branch being built:

echo "Starting build for branch:"
echo $bamboo_planRepository_branchName

if [ $bamboo_planRepository_branchName = "development" ] ; then
    echo "Executing mvn clean deploy -U"
    mvn clean deploy -U
else
    echo "Executing mvn clean install -U"
    mvn clean install -U
fi

$bamboo_planRepository_branchName is a variable provided by Bamboo.