Anurag Anurag - 2 months ago 44
Groovy Question

Job DSL Configure block to configure Sonar Properties in Jenkins Job

I am facing this particular error while configuring

<properties>
tag in config.xml

configure{ node ->
node / builders / 'hudson.plugins.sonar.SonarRunnerBuilder' {
project('')
properties((sonar.projectName): "project")
javaOpts('')
additionalArguments('')
jdk('')
task('')
}
}


**Error :**
ERROR: No such property: projectName for class: java.lang.String

Answer

You can not use maps as element values in configue blocks. You need to provide a string to configure the properties element:

job('example') {
  configure{ node -> 
    node / builders / 'hudson.plugins.sonar.SonarRunnerBuilder' {
      project('')
      properties('sonar.projectName=project')
      javaOpts('')
      additionalArguments('')
      jdk('')
      task('')
    }
  }     
}