I'm wondering if anyone knows whether it's possible to run job DSL from the Jenkins Script Console? Ideally I'd like to be able to run a groovy script from the command line using the Jenkins CLI 'groovy' command such that I can automate the creation of certain jobs.
I have the following script so far, which feels like it might be close. This runs, but produces an error in the jenkins log:
java.io.IOException: Unable to read C:\Program Files (x86)\Jenkins1.651\jobs\project-a\config.xml
It should be creating the file, so I'm not sure why it fails to read it, but it would be good to know if I'm on the right track?
import javaposse.jobdsl.dsl.*
import javaposse.jobdsl.plugin.*
JenkinsJobManagement jm = new JenkinsJobManagement(System.out, [:], new File('.'));
DslScriptLoader dslScriptLoader = new DslScriptLoader(jm)
dslScriptLoader.runScript("folder('project-a')")