Using Job-DSL we can configure a C# project in Jenkins.
The SonarQube tasks is giving us a hard time.
StepContext.metaClass.sonar = {
-> NodeBuilder nodeBuilder = new NodeBuilder()
stepNodes << nodeBuilder.'hudson.plugins.sonar.SonarRunnerBuilder' {
jdk('(Inherit From Job)')
usePrivateRepository(false)
}
}
How to set the path to the sonar-project.properties
config file, using the Job-DSL script?
Final script
Thanks to @Bruno César, I added pathToSonarProjectProperties
as parameter.
StepContext.metaClass.sonar = { String pathToSonarProjectProperties
-> NodeBuilder nodeBuilder = new NodeBuilder()
stepNodes << nodeBuilder.'hudson.plugins.sonar.SonarRunnerBuilder' {
jdk('(Inherit From Job)')
usePrivateRepository(false)
project(pathToSonarProjectProperties)
}
}
The sonar
function is called with the relative-to-project-root path of sonar-project.properties
:
sonar("Framework\\xxx\\xxx\\sonar-project.properties")
In SonarRunnerBuilder
class there is a project
attribute that represents the path to a file with properties for the project.
In the same way in which you set the JDK (jdk('(Inherit From Job)')
) you can set the path property. In your example, try like this:
StepContext.metaClass.sonar = {
-> NodeBuilder nodeBuilder = new NodeBuilder()
stepNodes << nodeBuilder.'hudson.plugins.sonar.SonarRunnerBuilder' {
jdk('(Inherit From Job)')
usePrivateRepository(false)
project('${your.path.here}')
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With