forked from AnalogJ/you-dont-know-jenkins-init
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3001.plugin-sonar.groovy
40 lines (34 loc) · 1.45 KB
/
3001.plugin-sonar.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import jenkins.model.Jenkins;
import jenkins.model.*;
import hudson.plugins.sonar.*;
println "///////////////////////////////////////////////////////////////////////////"
println "Init Hook: Sonar plugin"
println "///////////////////////////////////////////////////////////////////////////"
def instance = Jenkins.instance
def sonar_url = "https://sonar.corp.example.com"
def sonar_token = "12345"
def sonarGlobalConfiguration = instance.getDescriptor("SonarGlobalConfiguration")
def sonarInstallation = new SonarInstallation(
'sonar', //name
sonar_url, //serverUrl
'5.3', //serverVersion
sonar_token, //serverAuthenticationToken
'', //databaseUrl
'', //databaseLogin
'', //databasePassword
'', //mojoVersion
'', //additionalProperties
new hudson.plugins.sonar.model.TriggersConfig(), //triggers
'', //sonarLogin
'', //sonarPassword
'' //additionalAnalysisProperties
)
sonarGlobalConfiguration.setInstallations(sonarInstallation)
sonarGlobalConfiguration.save()
//configure the Sonar Scanner tool.
def sonarPluginExtension = Jenkins.instance.getExtensionList(hudson.plugins.sonar.SonarRunnerInstallation.DescriptorImpl.class)[0]
sonarPluginExtension.setInstallations(
new hudson.plugins.sonar.SonarRunnerInstallation('Default',null,
[new hudson.tools.InstallSourceProperty([new hudson.plugins.sonar.SonarRunnerInstaller('3.0.1.733')])]
)
)