Hello everyone,
I’ve been setting up a new Jenkins 2.8 with JobDSL 1.47.
I looked up and adhered to all change notes, and when it comes to a “conditional Steps” build step, I’m encountering the following error:
fileExists(projectName+'/target/windows/test/tests.exe', BaseDir.WORKSPACE)
--> No such property: BaseDir for class: javaposse.jobdsl.dsl.helpers.step.RunConditionContext
I remember encountering this with JobDSL version 1.34 already – my workaround was to import javaposse.jobdsl.dsl.helpers.step.RunConditionContext.BaseDir in the JobDSL file directly. If I do this now, I get the following error, which seems to make this a deadlocked situation:
Script1.groovy: 1: unable to resolve class javaposse.jobdsl.dsl.helpers.step.RunConditionContext.BaseDir
I am using a Groovy script to do set up a tailored environment for the JobDSL file (binding). It usually works perfectly. I’ve been trying a dozen things today to circumvent the above condition, including
- Direct import of j.j.d.h.s.*, j.j.d.h.s.RunConditionContext, j.j.d.h.s.RunConditionContext.BaseDir
- Indirect import of the Enum type (see below)
- The above steps with the former, deprecated classpath (it was redirected, the error remained)
- Searching for the class on the system in order to add it as classpath (didn’t find any on the system oO)
- Using filesMatch() instead of fileExists() (same error)
- Using FQN
- …
The most helpful, but also the most confusing output came when I imported javaposse.jobdsl.dsl.helpers.step.RunConditionContext.BaseDir into the top-level Groovy script, and then passed BaseDir.WORKSPACE in as an environment variable:
No signature of method: javaposse.jobdsl.dsl.helpers.step.ConditionalStepsContext.fileExists() is applicable for argument types: (java.lang.String, javaposse.jobdsl.dsl.helpers.step.RunConditionContext$BaseDir) values: [myProject/target/windows/test/tests.exe, WORKSPACE]
But this is exactly what fileExists() is defined to work with! I’m starting to think it must be something more basic, and I just didn’t see it. Or a bug.
Can anyone help?
Thanks,
Jennifer
Code snippet:
Closure jobClosure = {
steps {
conditionalSteps {
condition {
fileExists(projectName+'/target/windows/test/tests.exe', BaseDir.WORKSPACE)
}
runner('Fail')
steps {
batchFile(...)
}
}
}
}
return jobClosure