We’ve just updated to the Sonar 2.12 Jenkins plugin release, hoping to use the new cli: false syntax. Unfortunately, using the example as-is:
withSonarQubeEnv(‘SonarQube’, cli: false) {
}
I receive the error:
java.lang.IllegalArgumentException: Expected named arguments but got [{cli=false}, SonarQube]
If I try naming the first argument:
withSonarQubeEnv(‘SonarQube’, cli: false) {
}
I receive the error:
org.kohsuke.stapler.NoStaplerConstructorException: There’s no @DataBoundConstructor on any constructor of class java.lang.String
Caused: java.lang.IllegalArgumentException: Could not instantiate {installationName={installationName=SonarQube, cli=false}} for hudson.plugins.sonar.SonarBuildWrapper
which looks funky, as it’s trying to bundle up the cli argument and pass it to the constructor parameter.
This is odd, as the Jenkins pipeline documentation explicitly suggests combining DataBoundConstructor and DataBoundSetter:
Is there a recommended way to pass both? Does the example in the SonarQube documentation need updating?
Any update on this? I’ve also tried with envOnly: true as per:
but the errors are similar. Omitting the name of the installationName argument gives:
java.lang.IllegalArgumentException: Expected named arguments but got [{envOnly=true}, SonarQube]
including it yields:
org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class java.lang.String
at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:265)
at org.jenkinsci.plugins.structs.describable.DescribableModel.<init>(DescribableModel.java:153)
at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:474)
at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:409)
at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:329)
Caused: java.lang.IllegalArgumentException: Could not instantiate {installationName={installationName=SonarQube, envOnly=true}} for hudson.plugins.sonar.SonarBuildWrapper
As you can see from the post above, I’ve tried envOnly: true too, and am still getting errors indicating envOnly is not defined. We’ve upgraded the Sonar plugin to 2.12, should we be using a different version?
Sorry for the hideously late reply here. It turns out our scheduled Jenkins plugin updates didn’t happen, so (as you’d suspected) I wasn’t using the version with these changes. Using envOnly: true appears to be working a treat now, ta.