问题
I am using the JiraPlugin in Jenkins to produe a ReleaseNotes and my build job in Jenkins uses batch files.
In the executed batch file, when I just issue a set
, I can see that the varibale exists with the Jira Release notes. But it is multi-line and starts with a #
character.
my goal is to do a
echo %RELEASE_NOTES_JENKINS% > ReleaseNotes.txt
but that never works. I tried using !!
instead of %%
around the variable but that also does not work. I get ECHO is off.
when I try to echo the variable.
Again, set
does show it with the correct content:
RELEASE_NOTES_JENKINS=# New Feature
- [XXXX-3525] Blahblahblah
- [XXXX-3268] Blahblahblah
- [XXXX-3119] Blahblahblah
# UNKNOWN
- [XXXX-3545] [security] Blahblahblah
...
Jenkins runs on a Windows 7 Server. This is specific to windows Batch (cmd.exe) since simply piping the variable to a file works when the Jenkins runs on a Linux environment.
Any idea on how to make this work?
回答1:
Try
SET RELEASE_NOTES_JENKINS > ReleaseNotes.txt
instead of echo
.
回答2:
Delayed expansion should work:
setlocal enableDelayedExpansion
echo !RELEASE_NOTES_JENKINS!>releasenotes.txt
来源:https://stackoverflow.com/questions/31717777/windows-batch-echo-a-multi-line-variable-with-special-characters-jirarelease-n