Jenkins Job DSL Plugin - Reading in External File

6/25/2020

I'm having trouble with the Jenkins Job DSL Plugin. I can create the pipeline job via the plugin casc script, which is great. However, now I am trying to read in a csv file to autopopulate some parameters for it. readFileFromWorkspace is failing and readFile isn't working either. I'm trying like this: def file = readFileFromWorkspace("${ENV_VAR}file.csv") (which gives us /usr/share/jenkins/casc-configs/file.csv)

I verified file is present on the Jenkins Master at the above path (which is a Docker Container - running on Kubernetes). I can shell to the container and see it there.

Does anyone have experience with an effort similar to this? The errors I get are 'No signature of method: script.readFile() is applicable for argument types (org.codehaus.groovy.runetime.GStringImpl) values :( /file/location/here) <--- which I verified the file is present at this value on the Jenkins master container.

The readFileFromWorkspace error is: java.lang.NullPointerException at javaposse.jobdsl.plugin.JenkinsJobManagement.locateValidFileInWorkspace(JenkinsJobManagement.java:428)

-- Rob
groovy
jenkins
jenkins-job-dsl
kubernetes

0 Answers