In Bamboo, is there a way to always run a plan in customized mode?

Michael Smith December 4, 2014

Basically I have a duplicate plan for my developers so they can run there work on their branch instead of the integration line so that they can assure it passes all sanity tests.  This build only takes about 30 mins compared to the full two hours a normal clean build would take.  So it is not an exact duplicate.  Any rate all the branches are variables and set to the integration branch which is what the normal CI runs against.  My developers would change these variables to there branches and then run it.  In order to do this you have to "Run Customized ..."  I want Run to also require "Run Customized ..." that way they don't start a build without changing the parameters.

1 answer

1 vote
Caley Goff December 4, 2014

Michael-

From the sounds of things, we have a solution to a similar problem. Our solution is constructed in bash as we migrated from a Jenkins running in an UNIX environment to a Bamboo running in an UNIX environment... so naturally we use bash to do our bidding. I have since modified and ported it to Bamboo to make it work in our workflow. I am not sure how knowledgable  you are in bash, however with a little elbow grease I am confident the same concept can be applied in other languages as well. I just don't know if the script task can interpret  a language other than bash (I haven't tried honestly). 

 

Basically based on the branch name we can decide what to do. We utilize the following in a script task which I'm assuming you are already doing. 

 

We use the gitflow workflow so we using the following branching schema:

**** possible substitutions for `${bamboo.planRepository.branchName}` **** 
master
release-v1.2.3
hotfix/something_was_needed_now
develop
feature/HOD-1337

 

This particular block you can use if you just want the feature branch to do something different... 

#####Begin Bamboo Duplicate task for branches:
## Do the same things for each branch to prepare plan for execution...
## e.g.:
##WORKINGDIR=${bamboo.build.working.directory}
##cd $WORKINGDIR


#!/bin/bash
##Do same things for a specific branch or default things for everything else.
PLAN_BRANCH=${bamboo.planRepository.branchName}
BRANCH=$(echo $PLAN_BRANCH | cut -c 1-7 | sed 's/\///g');
if [[ "$BRANCH" = "feature" ]];
then
# do magic you would do in a feature branch here.
echo "features";
else
# do magic you would do for any other branch here.
echo "default things";
fi
## Finishing steps thats are the same for all branches... 
## e.g. Preparing test results 
##Finish Bamboo Duplicate task for branches

 

If you wish to have something run different for multiple branches with different names you can add a new if block for each branch name. e.g.:

#####Begin Bamboo Duplicate task for branches:
## Do the same things for each branch to prepare plan for execution...
## e.g.:
##WORKINGDIR=${bamboo.build.working.directory}
##cd $WORKINGDIR
 
#!/bin/bash
##Do same things for a specified branches or default things for everything else.
PLAN_BRANCH=${bamboo.planRepository.branchName}
BRANCH=$(echo $PLAN_BRANCH | cut -c 1-7 | sed 's/\///g');
if [[ "$BRANCH" = "feature" ]]; 
# do magic you would do in a feature branch here.
echo "features";
elif [[ "$BRANCH" = "hotfix" ]]; 
then 
# do magic you would do in a hotfix branch here.
echo "hotfix";
else 
# do magic for any other branch here.
echo "default things"; 
fi
## Finishing steps thats are the same for all branches... 
## e.g. Preparing test results 
##Finish Bamboo Duplicate task for branches

This may or not directly help you. I do however hope it plants the seed for an idea to improve on. 

 

Good luck.

Michael Smith December 5, 2014

This is not quite what I was looking for. It is a great solution if you want 'one' plan to be able to build differently based on branch info. However, I would like my normal plan untouched that only I have rights to, and allow developers to use another plan. However on that plan I want to remove the possibility to run without customizing parameters. I.E. The Run Customized Build always shows up and Override Variables is enabled by default. The whole idea of the plan is for developers to override the default branch with their branch. I do not want to take away from your solution as it solves a few problems I just looking for a more elegant way to do this through Bamboo.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events