在构建管道可视化设计器中,任务的YAML注释的目的是什么?

7

当我在构建流水线的可视化设计器中查看任务的YAML时,我会看到像以下这样的注释:

#Your build pipeline references an undefined variable named ‘Parameters.projects’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972

这是对我添加Parameters.projects变量的指示吗?还是只是为了在构建YAML流水线时提供参考?


2
生成的YAML至今仍未提供参数、变量和vmImage。它也不会提醒你这个YAML从输出中省略了什么...基本上,这些注释有点误导人。是的,这些变量/参数是未定义的——因为没有人花时间编写代码来包括这些参数/变量的初始化在YAML生成器中...你需要添加缺失的参数、变量和vmImage到生成的YAML中,以使流水线运行起来。这些值可以通过查看经典编辑器界面来发现。 - Derek Foulk
2
'Tasks > Pipeline > Agent Specification' 会显示 vmImage 的值。'Tasks > Pipeline > Parameters' 会显示所需的参数。最后,'Variables > Pipeline variables' 会显示变量。 - Derek Foulk
1个回答

8
这些更像是指导用户理解流程的指令。

E.g.:

这里的参数 (parameters.solution) 与值 **\*.sln 相关联。

enter image description here

这个的YAML是

#Your build pipeline references an undefined variable named ‘Parameters.solution’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references the ‘BuildPlatform’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
steps:
- task: VSBuild@1
  displayName: 'Build solution'
  inputs:
    solution: '$(Parameters.solution)'

    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'

    platform: '$(BuildPlatform)'

    configuration: '$(BuildConfiguration)'

现在我将取消此变量的默认值,并指向我的 sln 文件。

enter image description here

如果现在查看YAML文件,变量Parameters.solution不再需要,因为解决方案直接分配给了wcfapp.sln。在这种情况下,您将不会在YAML文件中看到任何注释。
#Your build pipeline references the ‘BuildPlatform’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
steps:
- task: VSBuild@1
  displayName: 'Build solution'
  inputs:
    solution: wcfapp.sln

    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'

    platform: '$(BuildPlatform)'

    configuration: '$(BuildConfiguration)'

这是否意味着,当我初始化变量时,构建仍然可以包含分配给变量的值或仍未定义? - aj go

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接