I have created the New Variable Group in Library of the Pipelines from which one variable’s value is locked and the another is not locked as you can see in below screenshot:
I’m trying to get/fetch these values in the pipelines:
trigger:
- main
pool:
vmImage: ubuntu-latest
variables:
- group: DevGroup
- name: buildSolution
value: '**/*.sln'
- name: buildPlatform
value: 'Any CPU'
- name: 'buildConfiguration'
value: 'Release'
- name: 'Poornasapproval'
value: 'yes'
steps:
- script:
echo -e $(buildSolution)
echo -e $(StorageAccName)
echo -e $(Location)
- powershell:
Write-Host "$(StorageAccName) is the Storage Account Name"
- powershell: |
"the value: $(StorageAccName)" | Out-File -FilePath $(Build.ArtifactStagingDirectory)DisplaySecret.txt
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
I have written two PowerShell scripts in which one can print the secret value to logs (command line) and to the text file.
To the text file, it is showing the value but in the logs, it is not showing the value.
It is showing asterisk symbols.
In the Text File:
Here the question is:
How do I can see the Variables value from the Logs or Azure DevOps UI or in the Pipelines if the value is secured/locked/protected.
Note: I’m the administrator of the organization, project, repository, pipelines.
2
Answers
If a variable’s value is secured/locked/protected, you may not be able to view its value directly from the logs or Azure DevOps UI. However, you can still access the variable’s value within your pipeline by using the appropriate syntax.
It is the whole point of secret variables that they are not visible in the pipeline or the logs, as explained in the Microsoft Documentation.