Set up a Jenkin SonarQube partition using Job-DSL

Using Job-DSL, we can customize a C # project in Jenkins.

The tasks of SonarQube give 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 configuration file path sonar-project.propertiesusing Job-DSL script?

Sonar section

Final script

Thanks @Bruno César, I added pathToSonarProjectPropertiesas a 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 function sonaris called using the path relative to the root project sonar-project.properties:

sonar("Framework\\xxx\\xxx\\sonar-project.properties")
+4
source share
1 answer

There SonarRunnerBuilderis an attribute projectrepresenting the path to the file with properties for the project.

, JDK (jdk('(Inherit From Job)')), . :

StepContext.metaClass.sonar = {
    -> NodeBuilder nodeBuilder = new NodeBuilder()
    stepNodes << nodeBuilder.'hudson.plugins.sonar.SonarRunnerBuilder' {
        jdk('(Inherit From Job)')
        usePrivateRepository(false)
        project('${your.path.here}')
    }
}
+4

Source: https://habr.com/ru/post/1584934/


All Articles