Hello!
I'm getting an error:
ERROR: (PrepareBuildPublish.groovy, line 42) No signature of method: javaposse.jobdsl.dsl.helpers.step.StepContext.readFileFromWorkspace() is applicable for argument types: (java.lang.String) values: [WorkspaceLocker.groovy]
in jenkins Process Job DSLs step when executing
main.groovy:
import models.*
import templates.*
import hudson.FilePath
import org.yaml.snakeyaml.Yaml
createJobs()
void createJobs() {
def yaml = new Yaml()
// Build a list of all config files ending in .yml
def cwd = hudson.model.Executor.currentExecutor().getCurrentWorkspace().absolutize()
def configFiles = new FilePath(cwd, 'ci-repos').list('*.yml')
//for each config create a job
configFiles.each { file ->
def projectConfig = yaml.loadAs(file.readToString(), ProjectConfig.class)
def project = projectConfig.project.replaceAll(' ', '-')
PrepareBuildPublish.create(job("${project}-Prepare-Build-Publish"), projectConfig)
}
}PrepareBuildPublish.groovy source (I removed irrelevant configuration blocks from it):
package templates
class PrepareBuildPublish {
static void create(job, config) {
job.with {
steps {
systemGroovyCommand(readFileFromWorkspace('WorkspaceLocker.groovy')){
binding('repo','${config.repo}')
classpath()
}
}
}
}
}
Please help understand why readFileFromWorkspace method is not found, what needs to be imported and where ?This code snippet worked when I used it directly in Jenkins Process Job DSLs plugin directly as a DSL script.
Thank you in advance
https://github.com/jenkinsci/job-dsl-plugin/blob/master/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/DslFactory.groovy#L328 that particular method is within the DslFactory context
Another similar question:
https://groups.google.com/forum/m/#!topic/job-dsl-plugin/xsgWi2wOEx8
Cheers
--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugin+unsubscribe@googlegroups.com.
To post to this group, send email to job-dsl-plugin@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/b90b12c1-dec7-4112-b8a9-447fb36ffa08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
steps {
systemGroovyScriptFile('WorkspaceLocker.groovy'){
binding('workdir',"${config.workdir}")
}
}