Bamboo Specs Support

Include Code Quality for Bamboo can be used together with Bamboo specs to use Configuration as Code for your plans.

Java Specs

Using Sonar for Bamboo tasks with Java Specs is supported by the Specs own AnyTask.

To see the Java Specs for one of the tasks:

  1. go to your plan configuration in Bamboo

  2. click “View plan as Java Specs”:

Within the generated Java Specs, your tasks will look similar to this example for a Sonar™ Scanner task:

new AnyTask( new AtlassianModule("ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.sonarscannertask")) .configuration( new MapBuilder() .put("chosenSonarConfigId", "1") .put("sonarMainBranch", "master") // many more task fields .build() ) ) ) )

 

YAML Specs

If you prefer YAML, you can also use the Include Code Quality for Bamboo tasks with YAML.

To see the YAML for one of the tasks:

  1. go to your plan configuration in Bamboo

  2. click “View plan as YAML”:

Within the generated YAML, the tasks will look similar to this example for a Sonar™ Scanner task:

- any-task: plugin-key: ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.sonarscannertask configuration: chosenSonarConfigId: '1' sonarMainBranch: master

 

Task Reference

Task keys for the provided tasks:

Task name

Task key

Task name

Task key

Sonar™ Maven 3 task

ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.maven3task

Sonar™Scanner task

ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.sonarscannertask

Sonar™ Gradle task

ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.gradletask

Sonar™ MSBuild begin task

ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.msbuildbegintask

Sonar™ MSBuild end task

ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.msbuildendtask

Sonar™ .NET Core begin task

ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.dotnetbegintask

Sonar™ .NET Core end task

ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.dotnetendtask

Sonar™ Maven 2 task (for 2.x versions only)

ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.maven2task

Sonar™Scanner task (for 2.x versions only)

ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.sonarscannertask

 

Option keys of the Include Code Quality for Bamboo tasks configuration fields:

Key

Description

Possible Values

Key

Description

Possible Values

sonarBranch

Sonar branch to use

e.g., master

sonarProjectName

Project name

e.g., MyProject

sonarProjectKey

Project key

e.g., myproject

sonarProjectVersion

Project version

e.g., 1.0

failBuildForSonarErrors

Fail build when SonarQube reports analysis errors

true/false

enableDebugBuildLog

Write Sonar for Bamboo debug log to build log (since version 3.1)

true/false

failBuildForBrokenQualityGates

Fail build when project has quality gate status FAILED
For Version 2.8 and older. Prefer `brokenQualityGateOption` in newer versions

true/false

brokenQualityGateOption

How the build uses Sonar Quality Gates. Leaving the key out will use the configured Server settings.
Supported from Version 2.9 or newer

  • skip: Ignore quality gates

  • show: Show quality gate status on build summary

  • break-build: Show and break build on broken quality gates

sonarPullRequestAnalysis

Use pull request analysis if possible (COMMERCIAL SonarQube editions only)

true/false

useGlobalSonarServerConfig

Use one of the configured SonarQube servers from the global administration.

true/false

sonarSources

Source locations

e.g., src

sonarTests

Test source locations

e.g., src/test

sonarLanguage

Programming Language

e.g., java

buildJdk

Build JDK, references the configured Bamboo JDK capabilities

e.g., jdk8

sonarJavaSource

Java source version

e.g., 1.8

chosenSonarConfigId

SonarQube server used for this task.

Get the config ID from the admin settings: Bamboo Admin → Sonar for Bamboo

Find the ID in the URL of a server configuration:

/admin/sonar4bamboo/editSonarServer.action?serverConfigId=1

e.g., 1

sonarMainBranch

Sonar main branch

e.g., develop

failBuildForTaskErrors

Fail build if the task execution result in error

true/false

incrementalMode

Enable incremental mode.

true/false

incrementalModeBambooUser

Bamboo user to connect Bitbucket Server for incremental mode.

e.g., peter

incrementalNoPullRequest

What to do if no pull request can be found for this branch to apply incremental mode.

  • incrementalModeFailBuildField

  • incrementalModeRunFullAnalysis

  • incrementalModeSkipTask

incrementalModeNotPossible

What to do if a branch does not match the regular expression for incremental mode.

  • incrementalModeRunFullAnalysis

  • incrementalModeSkipTask

incrementalFileForInclusionList

Write the inclusions file list to a file (Deprecated since 3.0)

true/false

illegalBranchCharsReplacement

Replacement for illegal branch characters (COMMUNITY SonarQube edition only)

Allowed characters are alphanumeric, '-', '_' and '.'.

legacyBranching

Use legacy branching (COMMUNITY SonarQube edition only)

true/false

replaceSpecialBranchChars

Invalid branch character replacement override (COMMUNITY SonarQube edition only)

true/false

additionalProperties

Additional parameters

e.g., -Dsome.property=some.value

autoBranch

Auto branch

true/false

overrideSonarBuildConfig

Override Sonar properties from build

true/false

workingSubDirectory

Working subdirectory for SonarQube analysis

e.g., multimod/src

 

SONAR™, SONARQUBE™ and SONARCLOUD™ are independent and trademarked products and services of SonarSource SA: see sonarsource.com, sonarqube.org, sonarcloud.io.