Changing a build parameter value with a new line
Answered
I'm reading a file that contains some additional parameters for sonarqube runner. Is it possible to set a parameter new value with a new line? I'm doing it using powershell.
This is the value of the from file which is stored in $properties variable.
-Dsonar.sourceEncoding=UTF-8
-Dsonar.exclusions=packages/**/*,**/*.xml,**/*.sql
echo "##teamcity[setParameter name='sonar.config' value='$properties']"
Output is:
##teamcity[setParameter name='sonar.config' value='-Dsonar.sourceEncoding=UTF-8
-Dsonar.exclusions=packages/**/*,**/*.xml,**/*.sql']
Looks like this not works if the value has a new line. Any suggestions will be helpful
Thanks
Please sign in to leave a comment.
Hello,
Service messages cannot contain a newline character inside it, it's "by design" and it's also noted in our documentation: https://confluence.jetbrains.com/display/TCD10/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-servMsgsServiceMessages. Please use parameters without newlines.
you can put a newline into a parameter by escaping it echo "##teamcity[setParameter name='sonar.config' value='line1|nline2']"
see https://www.jetbrains.com/help/teamcity/service-messages.html#Escaped+values