Jeff Trimmer
Jeff Trimmer

Reputation: 127

How to escape a single space in a travis ci encrypted environment variable?

Travis CI's user documentation has a section on how to escape secure environment variables. It seems not to work for the a single space. Is there anything special that needs done for the space character?

I tried to encrypt my sql server connection string like this

travis encrypt AzureSqlServerPath="Server=<server>\;Initial\ Catalog=<database>\;Persist\ Security\ Info=False\;User\ ID=<user>\;Password=<password>\;MultipleActiveResultSets=False\;Encrypt=True\;TrustServerCertificate=False\;Connection\ Timeout=30\;" --add --com

The variable is set fine but the spaces do not translate correctly to the environment variable. It truncates the string at the first space that is encountered.

Server=<server>;Initial 

Upvotes: 1

Views: 348

Answers (1)

Jeff Trimmer
Jeff Trimmer

Reputation: 127

I finally got something to work through trial and error. It seems that the solution was to use quotes within quotes and escape the inner quotes. Then I did not have to escape any other special character within the connection string.

travis encrypt AzureSqlServerPath="\"Server=<server>;Initial Catalog=<database>;Persist Security Info=False;User ID=<user>;Password=<password>;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;\"" --add --com

Upvotes: 2

Related Questions