-
Bug
-
Resolution: Duplicate
-
Minor
The following script runs fine in the Script Console but not in a Job DSL script.
import jenkins.* import jenkins.model.* import hudson.* import hudson.model.* def credentials = Jenkins.instance.getExtensionList(com.cloudbees.jenkins.GitHubPushTrigger.DescriptorImpl.class)[0].getCredentials() if(credentials.size() > 0) { credentials.each { if(it.apiUrl.length() > 0) { println("apiUrl: " + it.apiUrl) } else { println("apiUrl: https://api.github.com/") } println("username: " + it.username) println("oauthAccessToken: " + it.oauthAccessToken) } }
I recall that the Job DSL plugin executes groovy scripts in the Jenkins runtime. I'm getting info out of the configured github plugin (specifically the automatically manage hooks section).
Can you see anything that I'm obviously doing wrong? Also, there's this text from the script console: "All the classes from all the plugins are visible." The same does not appear to apply in Job DSL scripts.
Any advice is appreciated.
- duplicates
-
JENKINS-27517 Allow access to the Jenkins instance and/or plugins
- Open