Search code examples
azure-pipelines-release-pipeline

Not able to get the secret variable value in Release Pipeline


I am using secret variable in Azure DevOps release pipeline.

But I accidentally deleted the secret variable in release pipeline.

After checking, I found that the same variable is used in another release pipeline.

But it seems that there is no method to get the Secret Variable value of the release Pipeline.

Is there any methods or Rest APIs can get the Release Pipeline Secret variable value?

I tried to use the Rest API: https://learn.microsoft.com/en-us/rest/api/azure/devops/release/definitions/get?view=azure-devops-rest-7.1&tabs=HTTP to get the Release Definition. But it not shows the secret variable value.


Solution

  • I am afraid that there is no out-of-box method can directly get the Secret Variable value in Release Pipeline.

    To meet your requirement, we can output the secret variable value to a file in release pipeline. Then we can use logging command: UploadFile: Upload a file that can be downloaded with task logs to upload the related file to Pipeline log.

    Here is an example:

    $env:secret| Out-File $(System.DefaultWorkingDirectory)\output.txt
    
    Write-host "##vso[task.uploadfile]$(System.DefaultWorkingDirectory)\output.txt"
    

    enter image description here

    Finally, we can download the Release Pipeline log to check the secret variable value in the output file.

    enter image description here