Is there an easy way to override a global variable only on the the default plan? Edited

I want to run sonar qube analysis only on the latest code in the default branch (hg repo, corresponds to master in git).

I have also some integration branches that run the same plan, but should skip sonar analysis.

For this I have a global variable skipSonar=true.

Now I want to set the variable on the default branch to true.

The only way I can achieve this is to create a branch plan for default and set the variable on that branch.

The problem with this is: now I have two plans building the default branch.

Is there a better way?

2 answers

1 accepted

This widget could not be displayed.

When I need a build to behave on branches only in a certain way, I use plain-old-bash:

if [[ "${bamboo.planRepository.branchName}" == "master" ]]; then

  # do something

else

  # do another thing

fi

You might want to combine with environments variables to use certains commands:

JAVA_HOME="${bamboo.capability.system.jdk.JDK 8}" MAVEN_HOME="${bamboo.capability.system.builder.maven.Maven 3}"

(and you might also want to add the requirements manually to the job).

 

If your maven/gradle build generates junit tests reports, make sure to add a final task with JUnit parser :)

 

 

Thanks for your answer. This approach would have the advantage that you can fail the build with sonarqube quality gateways, since there is only one plan per artifact.

The downside is that it is not OS agnostic (we have to build on both Windows and Linux) and it also makes the plan more complicated. But still, this might be the solution I will got for... The script would have to set an environment that triggers a Maven profile or turns on the sonar plugin.

This widget could not be displayed.

Hi Martin! How are you doing?

I did not find a better solution than this. The only way we found to run SonarQube in a specific branch was creating two plans in Bamboo.

Thanks for yoour answer.

The disadvantage with having a separate plan is that you cannot use sonarqube quality gateways to fail a build. I had hoped that there was some functionality in Bamboo that would support this workflow.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

99 views 1 0
Join discussion

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