I have variables in several projects that are substitutes the original config
file value.
For instance, in project X the config
key is smtpServ
, and in project Y it's smtp
.
I'd like to have 1 variable in a library set named smtpServer
that should enter into smtpServ
(project X) and smtp
(project Y), so that I can keep it in 1 place.
Is this doable in the "Project Variables" view? (/projects/service-name/variables
), or do I need to do it with a PS script?
You can reference the library variable value in your project-specific variables.
For example, in project X, you can create a variable named smtpServ
that has a value of #{smtpServer}
. In project Y, you can create a variable named smtp
that has a value of #{smtpServer}
.
Then you can update the value of smtpServer
once instead of N number of times.
I will add a note of caution here that with generic names like this, there is a chance for a collision between the names. Say that project Z already has a variable named smtpServer
. In this case, you can't use the value #{smtpServer}
because it would be an infinite loop. Likewise, if any other variable referenced smtpServer
, it will use the project value and not the library set variable. The solution here could be to delete the smtpServer
variable from the project.
I prefer to give my variable names a prefix if possible. I may name the library variable global.smtpServer
and reference it as #{global.smtpServer}
to make a collision less likely.