I am trying to setup testing for my Job DSL scripts and I’ve managed to come a decent way to get things working and I have hit a snag. This should be a pretty quick and easy question I think.
I want to run a test on setting a hiddenParam on a job, which requires the hidden-parameter plugin. I’m currently getting the following error:
HiddenParametersSpec > Test HiddenParameter FAILED
groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.dsl.helpers.BuildParametersContext.hiddenParam() is applicable for argument types: (String, String, String) values: [test-param, some hidden parameter value, some hidden parameter]
Possible solutions: fileParam(java.lang.String, java.lang.String), runParam(java.lang.String, java.lang.String, java.lang.String)
at app//javaposse.jobdsl.dsl.AbstractExtensibleContext.methodMissing(AbstractExtensibleContext.groovy:19)
at uk.co.dsohub.jenkins.automation.parameter.HiddenParameter.toDsl_closure1(HiddenParameter.groovy:19)
at uk.co.dsohub.jenkins.automation.parameter.HiddenParameter.toDsl_closure1(HiddenParameter.groovy)
at app//javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:16)
at app//javaposse.jobdsl.dsl.Job.parameters(Job.groovy:317)
at uk.co.dsohub.jenkins.automation.builder.PipelineJobBuilder.build_closure1$_closure3(PipelineJobBuilder.groovy:74)
at uk.co.dsohub.jenkins.automation.builder.PipelineJobBuilder.build_closure1(PipelineJobBuilder.groovy:73)
at app//javaposse.jobdsl.dsl.JobParent.processItem(JobParent.groovy:248)
at app//javaposse.jobdsl.dsl.JobParent.pipelineJob(JobParent.groovy:87)
at app//uk.co.dsohub.jenkins.automation.builder.PipelineJobBuilder.build(PipelineJobBuilder.groovy:64)
at uk.co.dsohub.jenkins.automation.parameter.HiddenParametersSpec.Test HiddenParameter(HiddenParameterSpec.groovy:22)
This is where I am using the DSL to apply the hiddenParam:
@Override
Closure toDsl() {
return {
hiddenParam(
this.getName(),
this.getDefaultValue(),
this.getDescription()
)
}
}
Now, I’ve read this small paragraph on this page:
“The dynamic DSL is only supported when running in Jenkins, e.g. it is not available when running from the command line or in the Playground. Use The Configure Block to generate custom config elements when not running in Jenkins.”
I am using Jenkins Test Harness, so there is an in-memory Jenkins instance being span up, so I’m wondering does this paragraph apply?
“dynamic DSL is only supported when running in Jenkins” - and I have an in-memory instance with Jenkins Test Harness, so does this count as running?
If not, then I guess I am just forced to use a configure block, which is slightly less sexy, but oh well.