I'm passing some TeamCity parameters to the command line build step. The problem comes when the parameter value contains spaces, e.g.:
%env.TEAMCITY_BUILDCONF_NAME% ---> My TC Project
Is there a way to replace white spaces with some other character, for example underscore?
%env.TEAMCITY_BUILDCONF_NAME% ---> My_TC_Project
You can typically keep using the white spaces if you wrap the parameter in double quotes:
%program.files.dir%
=> C:\Program Files (x86)
Executable: dir
Parameters: "%program.files.dir%"
I don't know how to replace spaces with underscore, but I had an issue with whitespaces. In a TeamCity build step, I was trying to run an sqlcmd as Executable with Parameters
-S %sql_server% -U %sql_username% -P %sql_password%
-i "custom_script.sql" -d "%custom_db%"
-v DealerName="%DealerName%"
where DealerName was "Great Dealer Ltd" but it didn't work with white spaces, even with double quotes.
It fixed the issue by setting it as a Custom Script like
sqlcmd -S %sql_server% -U %sql_username% -P %sql_password%
-i "custom_script.sql" -d "%custom_db%"
-v DealerName="%DealerName%"
and (thanks to my boss suggestion) it worked like charm.
Even if is not the precise answer to your question, it could be useful for similar issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With