Save output from a command to a temporary environment variable
Completed
I am trying to save a git log commit message to an environment variable but for some reason when I run the Command Line build step, the output just returns the command itself as a string instead of the result of running the command.
The build agent is being hosted on a Windows machine.
Current implementation:
set ticket="git log -1 --pretty=format:%%%s"
echo "JIRA ticket found: %%ticket%%"
Expected
JIRA ticket found: <any previous commit message>
Actual
JIRA ticket found: "git log -1 --pretty=format:%s"
Any help would be greatly appreciated. Thanks!
Please sign in to leave a comment.
I had also tried setting the environment variable as so:
set ticket=${git log -1 --pretty=format:%%%s}
I figured it out by using for /f
git log -1 --pretty=format:%%%s >> out.tmp
for /f "tokens=1 delims=:" %%%A in (out.tmp) do set ticket=%%%A
del out.tmp