[workflow-plugin] How to assign output of a sh([script:""])

43 views
Skip to first unread message

Vizionz

unread,
Mar 6, 2015, 8:33:27 PM3/6/15
to jenkins...@googlegroups.com
When writing a workflow script, what is the best way to assign the output of a shell script to a variable in groovy?

For this example, the output is a number that I intend to pass as a parameter to another job.

Example Code:

node('Builder')
{
dir("/diretory/to/git/REPO")
{
GitCommitCountValue=sh([script: "git rev-list HEAD --count"])
print "Git Commit Count = ${GitCommitCountValue}"
}
}

Output:

[REPO] Running shell script
+ git rev-list HEAD --count
99
Running: Print Message
GIT COMMIT COUNT = 0


Thank you in advance,
Vizionz

Vizionz

unread,
Mar 6, 2015, 8:47:08 PM3/6/15
to jenkins...@googlegroups.com
Two minutes after posting...


Looks as though there is no easy way to return output/status from a shell script instance.

Reply all
Reply to author
Forward
0 new messages