Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Tokens tasks doesn't support secret connection strings #146

Closed
sussexrick opened this issue May 22, 2020 · 2 comments
Closed

Replace Tokens tasks doesn't support secret connection strings #146

sussexrick opened this issue May 22, 2020 · 2 comments

Comments

@sussexrick
Copy link

It appears that replacing a connection string as one token with a secret variable doesn't work, because a connection string will contain ; and your code is splitting on that to separate the variables.

In your readme for Replace Tokens you say that the implementation of secret variables can be made a lot better once this issue is fixed. I'm not sure because it was closed due to inactivity but I think it might be fixed - it references this commit which appears to be updating the retrieval of secret variables. I'm not sure if this is exactly the scenario you need though.

Alternatively, an extra property on the task allowing the ability to specify a different separator would do the trick.

@colindembovsky
Copy link
Owner

Hi @sussexrick thanks for logging this. The referenced issue is not related to this problem.

I think the separator is a requirement for backward compatibility to older versions of Azure DevOps Server (circa 2015). Newer versions of Azure DevOps Server and Azure DevOps (online) don't use the separator for secrets. However, when I've had this issue, I've coached teams to use a single token (__conStr__) for the connection string. Then in the variables, you create a "munged" variable called conStr that has placeholders for values. Something like this:

Variable Value
conStr Data Source=$(DBServer),1433;Initial Catalog=$(DBName);User ID=$(DBUsername);Password=$(DBPassword);
DBServer Name of database server
DBName Name of database
DBUsername Username to connect to database
DBPassword Password for user

Of course the password should be marked as a secret or even retrieved from KeyVault using a variable group.

@sussexrick
Copy link
Author

Thanks @colindembovsky, I'll give that a try. I had attempted something similar but obviously didn't quite get the syntax right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants