I have created a Groovy script which is used in a System Groovy Script
step in a Jenkins job which needs to access the current build of the current job.
T
This completes the answer from luka5z to exemplify how scriptler passes the listener to the groovy script:
import jenkins.model.*;
import hudson.model.*;
import hudson.util.*;
import hudson.tasks.*;
import hudson.plugins.git.*;
import hudson.scm.*
import jenkins.scm.*
def build = Thread.currentThread()?.executable
//def svn_branch = build.buildVariableResolver.resolve("SVN_BRANCH")
if (build instanceof AbstractBuild){
def workspace = build.workspace
//def job = build.parent
def scm = build.parent.scm;
//println "scm: $scm"
if (scm instanceof hudson.scm.SubversionSCM) {
scm.checkout(build, null/*Launcher*/, workspace /*workspace*/, listener/*listener*/, null /*changelogfile*/,null/*baseline*/)
}else if (scm instanceof hudson.plugins.git.GitSCM) {
scm.checkout(build, null/*Launcher*/, workspace /*workspace*/, listener/*listener*/, null /*changelogfile*/,null/*baseline*/)
}
}
listener in Scriptler