I set up a CSV file with my job parameters, and all the jobs are built from there. I originally had this weird system that turned the CSV into XML and used the XML slurper to read the values in. That worked OK for some reason, but reading the CSV directly is not. Here is some more info:
Both the DSL (build_all_jobs.groovy) and the CSV (doc_builds.csv) are in the jenkins_templates/ directory in the workspace (from Git).
In the Jenkins job, I configured it to "look on the filesystem" for the DSL, and pointed it to jenkins_templates/build_all_jobs.groovy.
I'm having trouble getting the DSL to "see" the CSV file. I load it like this (I also tried "doc_builds.csv" and "jenkins_templates/doc_builds.csv" in the File() invocation):
new File( "${WORKSPACE}/jenkins_templates/doc_builds.csv" ).withReader { r ->
parseCsv( r ).each { ...
In the Jenkins job, I added a step to run some commands before the DSL, so I could debug what's visible to the Jenkins job itself:
Current working directory is /var/lib/jenkins/workspace/generate_doc_jobs
Contents of the jenkins_templates directory are
total 132
-rw-rw-r-- 1 jenkins jenkins 27109 Apr 20 21:06 build_all_jobs.groovy
-rw-rw-r-- 1 jenkins jenkins 10373 Apr 20 20:40 doc_builds.csv
-rw-rw-r-- 1 jenkins jenkins 13443 Apr 20 20:40 doc_builds.json
-rw-rw-r-- 1 jenkins jenkins 45056 Apr 20 20:40 doc_builds.xls
-rw-rw-r-- 1 jenkins jenkins 2535 Apr 20 20:40 GroovyExcelParser.groovy
-rw-rw-r-- 1 jenkins jenkins 5794 Apr 20 20:40 html_build.dsl
-rw-rw-r-- 1 jenkins jenkins 5569 Apr 20 20:40 pdf_build.dsl
-rw-rw-r-- 1 jenkins jenkins 6052 Apr 20 20:40 qa_build.dsl
-rw-rw-r-- 1 jenkins jenkins 474 Apr 20 20:40 README.adoc
Then it sets up Groovy and launches the DSL, which prints out the contents of user.dir and user.home to start with, then tries to load the CSV and bombs out with a FileNotFoundException:
Setting GROOVY_1_8_7_HOME=/var/lib/jenkins/tools/hudson.plugins.groovy.GroovyInstallation/groovy_1.8.7
Working directory is /
Home directory is /var/lib/jenkins
FATAL: Unable to run script
java.io.IOException: Unable to run script
at javaposse.jobdsl.dsl.DslScriptLoader.runDslEngineForParent(DslScriptLoader.java:74)
at javaposse.jobdsl.dsl.DslScriptLoader.runDslEngine(DslScriptLoader.java:93)
at javaposse.jobdsl.plugin.ExecuteDslScripts.perform(ExecuteDslScripts.java:150)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:566)
at hudson.model.Run.execute(Run.java:1665)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:246)
Caused by: java.io.FileNotFoundException: /var/lib/jenkins/workspace/generate_doc_jobs/jenkins_templates/doc_builds.csv (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at groovy.util.CharsetToolkit.<init>(CharsetToolkit.java:69)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.newReader(DefaultGroovyMethods.java:16042)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(DefaultGroovyMethods.java:16099)
at org.codehaus.groovy.runtime.dgm$914.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at build_all_jobs.run(build_all_jobs.groovy:8)
at javaposse.jobdsl.dsl.DslScriptLoader.runDslEngineForParent(DslScriptLoader.java:69)
... 11 more
Any ideas what dumb thing I am doing wrong this time?