Reputation: 119
I am hoping to use a Groovy script that generates a list of jobs on a Jenkins instance as a build parameter. The script works in Jenkins' Script Console:
but does not work in the job:
I get the same result if I import
any of jenkins.*
, jenkins.model.*
, hudson.*
, or hudson.model.*
into the script, as referenced in the Script Console.
When I try to test the script in Configure, I am unable to with or without using the Groovy Sandbox. What am I missing? Thanks in advance.
Upvotes: 0
Views: 1018
Reputation: 12255
You missing some imports:
import jenkins.model.*
import hudson.model.*
jobNames = []
Jenkins.instance.getAllItems(Job.class).each{
jobNames.add(it.name.toString())
}
return jobNames
Upvotes: 1