Skip to content

Instantly share code, notes, and snippets.

@cheeming
Created June 1, 2012 09:37
Show Gist options
  • Save cheeming/2850764 to your computer and use it in GitHub Desktop.
Save cheeming/2850764 to your computer and use it in GitHub Desktop.
Groovy script to get git HEAD to be used in Jenkins
import hudson.FilePath;
import hudson.util.StreamTaskListener;
import hudson.plugins.git.GitAPI;
import hudson.EnvVars;
j = Jenkins.instance.getJob("codility");
workspace_path = j.getRootDir().toString() + "/workspace";
workspace = new FilePath(new File(workspace_path));
listener = new StreamTaskListener();
envvars = new EnvVars();
scm = new GitAPI("git", workspace, listener, envvars, "");
result = scm.revParse("HEAD")
result.getName();
@cheeming
Copy link
Author

cheeming commented Jun 1, 2012

Hmmm, seems the Dynamic Parameter plugin don't work well with import of plugins... I wonder why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment