How do I use a secret variable in a vsts release task?

Viewed 4923

I've got a release definition in vsts that needs access to a password I've defined as a secret variable in a variable group. I've linked that group to this release definition but when I run the task the parameter ends up blank. Is there anything special I need to do to get the value of a secret variable?

Definition of the powershell task that uses the password

Task definition

Linked variable group

Variable definition

Error output:

2017-08-09T14:01:17.9262375Z ##[command].            'C:\agent_work\r1\a\$(AGENT.BUILDDIRECTORY)\RCV\deploys\common\Get-FromArtifactory.ps1' -repoUsername developer -repoPassword  -repoPath libs-snapshot-local
2017-08-09T14:01:18.8168538Z ##[error]C:\agent_work\r1\a\$(AGENT.BUILDDIRECTORY)\RCV\deploys\common\Get-FromArtifactory.ps1 : Missing an argument for parameter 'repoPassword'. Specify a parameter of type 'System.String' and try again.

Edited to add more info as requested.

This is the start of my Get-FromArtifactory.ps1

[CmdletBinding()]
param (
    [Parameter(Mandatory)]
    [String]
    $repoUsername,

    [Parameter()]
    [String]
    $repoPassword,

    # Other params
)
#setup credentials object for arty access
$secPassword = $repoPassword | ConvertTo-SecureString -asPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($repoUsername, $secPassword)

Edit 15/08/2017 - I've updated it to use quotes as suggested by @Marina-MSFT but it's still just passing in blank.

Amended script to print out part of password:

[CmdletBinding()]
param (
    [Parameter(Mandatory)]
    [String]
    $repoUsername,

    [Parameter()]
    [String]
    $repoPassword,

#other params
)
write-host "pword $repoPassword"
write-host "1st char: $($repoPassword[0])"

enter image description here

2017-08-15T09:23:00.8606081Z ##[command]. 'C:\agent_work\r1\a\RCV\deploys\common\Get-FromArtifactory.ps1' -repoUsername developer -repoPassword "" -repoPath libs-snapshot-local -artifactName ipo-deposit-accounts_2.11 -artifactPath uk/gov/ipo -artifactVersion 0.1-SNAPSHOT -downloadDir C:\agent_work\r1\a
2017-08-15T09:23:02.3606174Z pword     
2017-08-15T09:23:02.3606174Z 1st char: 

Same with single quotes enter image description here

2017-08-15T09:22:10.6573655Z ##[command]. 'C:\agent_work\r1\a\RCV\deploys\common\Get-FromArtifactory.ps1' -repoUsername developer -repoPassword '' -repoPath libs-snapshot-local -artifactName ipo-deposit-accounts_2.11 -artifactPath uk/gov/ipo -artifactVersion 0.1-SNAPSHOT -downloadDir C:\agent_work\r1\a
2017-08-15T09:22:11.2198723Z pword 
2017-08-15T09:22:11.3761178Z 1st char: 
1 Answers
Related