Git commit counter with system Groovy??

15 views
Skip to first unread message

Brantone

unread,
Oct 2, 2015, 4:47:13 AM10/2/15
to Jenkins Users
It almost feels like this should be pretty basic functionality, but thus far in my searches : no luck.

Looking to just get the Git commit counter.
I know I can use "git rev-list HEAD --count" from within the workspace, but for various reason I'm using groovy and need to set it as a parameter during build execution (using ParametersAction). Because of this, using system groovy, so running on master ... which means need to connect to slave ... so after massaging, came up with:

def git_count_cmd = "def proc = 'git rev-list HEAD --count'.execute(null, new File('${build.getProject().workspace.toString()}')); proc.waitFor(); println proc.text"
def git_counter = RemotingDiagnostics.executeGroovy(git_count_cmd, build.workspace.channel).trim()


But that just seems like a lot of work to get a Git commit counter ... did I over-complexify? Is there a simpler method?


Thanks.
Reply all
Reply to author
Forward
0 new messages