I am having trouble accessing the jenkins global password as an environment variable in powershell. I have done the following. Not sure what else I am missing.
Don't confuse EnvInject plugin and Credentials Binding plugin. The two do quite different things, however both allow the manage passwords globally, yet differently.
$env:VAR_NAME
VAR_NAME
is the environment variable name (i.e. step 2 from EnvInject way, or step 4 from Credentials Binding way)EnvInject vs Credentials Binding
Username with Password vs Secret Text.
username:password
.secret
.In our build we use it the following way (actual code):
$deploymentdir = $env:VC_RES + "\azure"
. ".\src\Extensions\Setup\VirtoCommerce.PowerShell\deploy-tfs.ps1" -deployment $deploymentdir -solutiondir $env:WORKSPACE
and then pass $deploymentdir as a parameter to ps1, works fine.
The environment variable VC_RES is configured under "Manage Jenkins"->Global Properties. There is a checkbox next to "Environment Variables" and we set those in there. The WORKSPACE variable is set by jenkins itself.