adding extra properties to sonar publisher

Allows you to explicitly set which sonar configuration to use
for the sonar analysis when having more than one sonar installation.
In this case you are required to select which one to use,
as there is no default fallback in the Jenkins plugin itself.

Also added a similar option for configuring the maven installation
to use. This does have a default value, the version used in the
maven build in the same job. However, if for some reason you
need a different version of maven for sonar analysis you
have to be able to configure which one.

Adds parameter installation-name for the sonar configuration,
and maven-installation-name for the maven configuration.

Change-Id: I013ea80688efa17334448e6394d312ca6854cf07
This commit is contained in:
Joost van der Griendt 2016-08-13 23:03:58 +02:00 committed by Kien Ha
parent 18bf3239c0
commit beeb50564e
3 changed files with 13 additions and 1 deletions

View File

@ -2788,6 +2788,7 @@ def sonar(registry, xml_parent, data):
<http://docs.sonarqube.org/display/SONAR/\
Analyzing+with+SonarQube+Scanner+for+Jenkins>`_
:arg str installation-name: name of the Sonar instance to use (optional)
:arg str jdk: JDK to use (inherited from the job if omitted). (optional)
:arg str branch: branch onto which the analysis will be posted (default '')
:arg str language: source code language (default '')
@ -2796,6 +2797,8 @@ def sonar(registry, xml_parent, data):
(default false)
:arg str maven-opts: options given to maven (default '')
:arg str additional-properties: sonar analysis parameters (default '')
:arg str maven-installation-name: the name of the Maven installation
to use (optional)
:arg dict skip-global-triggers:
:Triggers: * **skip-when-scm-change** (`bool`): skip analysis when
build triggered by scm (default false)
@ -2831,9 +2834,14 @@ def sonar(registry, xml_parent, data):
sonar = XML.SubElement(xml_parent, 'hudson.plugins.sonar.SonarPublisher')
sonar.set('plugin', 'sonar')
if 'installation-name' in data:
XML.SubElement(sonar, 'installationName').text = data[
'installation-name']
if 'jdk' in data:
XML.SubElement(sonar, 'jdk').text = data['jdk']
if 'maven-installation-name' in data:
XML.SubElement(sonar, 'mavenInstallationName').text = data[
'maven-installation-name']
mappings = [
('branch', 'branch', ''),

View File

@ -2,7 +2,9 @@
<project>
<publishers>
<hudson.plugins.sonar.SonarPublisher plugin="sonar">
<installationName>MySonar</installationName>
<jdk>MyJdk</jdk>
<mavenInstallationName>Maven3.3.3</mavenInstallationName>
<branch>myBranch</branch>
<language>java</language>
<rootPom>mypom.xml</rootPom>

View File

@ -1,10 +1,12 @@
publishers:
- sonar:
installation-name: MySonar
jdk: MyJdk
branch: myBranch
language: java
root-pom: mypom.xml
private-maven-repo: true
maven-installation-name: Maven3.3.3
maven-opts: -DskipTests
additional-properties: -DsonarHostURL=http://example.com/
skip-global-triggers: