您好,我有一个小片段可以在 Azure DevOps 上运行。
steps:
- script: |
set ARTEFACTNAME=lorem.txt
echo ##vso[task.setvariable variable=psJobVariable;isOutput=true]%ARTEFACTNAME%
echo "lorem ipsum dolor" > %ARTEFACTNAME%
displayName: 'compile_windows'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/$(compile_windows.psJobVariable)'
ArtifactName: 'ci_test_windows'
publishLocation: 'Container'
displayName: 'publish windows'
发布的错误是:
##[error]Publishing build artifacts failed with an error: Not found PathtoPublish: D:\a\1\s\$(compile_windows.psJobVariable)
表示该变量未设置
我可以确认它创建了包含内容的 lorem.txt 文件,但 ist 没有为发布步骤创建 PipeLine 变量“psJobVariable”? 需要改变什么才能使这项工作正常进行?
我在“echo ##vso[...”行周围尝试了几个“但没有帮助。
我希望将此变量设置为 lorem.txt
您不要使用
$(myTaskDisplayName.myVar)
引用输出变量,而是使用 $(myTaskName.myVar)
。
steps:
- script: |
set ARTEFACTNAME=lorem.txt
echo ##vso[task.setvariable variable=psJobVariable;isOutput=true]%ARTEFACTNAME%
echo "lorem ipsum dolor" > %ARTEFACTNAME%
displayName: 'compile_windows' # this is the task display name
name: 'compile_windows' # this is the task name
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/$(compile_windows.psJobVariable)'
ArtifactName: 'ci_test_windows'
publishLocation: 'Container'
displayName: 'publish windows'