命令行脚本中 Azure devops 管道中的秘密变量不会更改为星号 *******

Secret variable in Azure devops Pipeline in command line script does not get changed to stars *******

我正在尝试在 azure 管道中签署一些文件,我添加了 .pfx 密码作为秘密并尝试在 - script 命令中使用它,但无论出于何种原因它似乎没有得到已映射。

脚本的相关部分

 - script: 
      $(pathToSignTool) sign /f $(pathToPfx) /p %MAPPEDPASS% Some.vsto
  env:
    MAPPEDPASS: $(pfxPassword)

输出为

Generating script.
Script contents:
C:\"Program Files (x86)"\"Windows Kits"\bin.0.19041.0\x64\signtool.exe sign /f C:\DirWhereThePfxIs\key.pfx /p %MAPPEDPASS% Some.vsto

据我所知,如果映射可行,它将变成 **** 而不是停留 %MAPPEDPASS%

我也试过 $(MAPPEDPASS)$(env:MAPPEDPASS)$MAPPEDPASS 都没有成功。

如何在命令行脚本中映射 Azure devops Pipeline 中的 Secret 变量?

编辑:添加了完整的 yaml

# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net

trigger:
- main

pool:
  name: 'XXX Build Pool'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  #change to actual directory where signtool is.
  pathToSignTool: "C:\\"Program Files (x86)\"\\"Windows Kits\"\10\bin\10.0.19041.0\x64\signtool.exe" 
  #change to actual directory where .pfx is.
  pathToPfx: "C:\DirWhereThePfxIs\XXX.pfx" 

steps:
# commented out nuget as we have an issue 
# but can't use workaround as currently no packages.config exist
#- task: NuGetToolInstaller@1
#
#- task: NuGetCommand@2
#  inputs:
#    command: 'custom'
#    arguments: 'restore YourProjectName\packages.config -PackagesDirectory $(Build.SourcesDirectory)\packages'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- script: 
      $(pathToSignTool) sign /f $(pathToPfx) /p %MAPPEDPASS% XXX.vsto
  env:
    MAPPEDPASS: $(pfxPassword)
    # add actual password to variables (top right corner of this window) as it is 123456 now.

- script: 
      $(pathToSignTool) sign /f $(pathToPfx) /p %MAPPEDPASS% XXX.dll.manifest
  env:
    MAPPEDPASS: $(pfxPassword)

- script: 
      $(pathToSignTool) sign /f $(pathToPfx) /p %MAPPEDPASS% XXX.dll
  env:
    MAPPEDPASS: $(pfxPassword)

 

预期行为不会将其更改为 ******,而是保持 %MAPPEDPASS%