mak*_*kil 5 continuous-integration yaml azure continuous-deployment azure-devops
我正在尝试使用扩展作为我的管道的一部分。我正在尝试从 Azure 文档开始工作的第一个基本步骤,即
# pythonparameter-template.yml
parameters:
- name: usersteps
type: stepList
default: []
steps:
- ${{ each step in parameters.usersteps }}
- ${{ step }}
# azure-pipelines.yml
trigger: none
resources:
repositories:
- repository: CI-CD-Templates
type: git
name: /CI-CD-Templates
ref: refs/heads/master
extends:
template: /pythonparameter-template.yml@CI-CD-Templates
parameters:
usersteps:
- script: echo This is my first step
- script: echo This is my second step
Run Code Online (Sandbox Code Playgroud)
我不断收到以下错误:
在此上下文中不允许使用指令“每个”。嵌入在字符串中的表达式不支持指令。仅当整个值是表达式时才支持指令 意外值 '${{ each step in parameters.usersteps }} - ${{ step }}'
同样在我从模板扩展之后,azure-pipelines.yml 也有它自己的自定义步骤,即
# azure-pipelines.yml
resources:
repositories:
- repository: templates
type: git
name: MyProject/MyTemplates
ref: tags/v1
extends:
template: template.yml@templates
parameters:
usersteps:
- script: echo This is my first step
- script: echo This is my second step
steps:
- template: /validation-template.yml@CI-CD-Templates
parameters:
commitMessage: $(commitMessage)
- template: /shared-template.yml@CI-CD-Templates
parameters:
buildArtifactDir: $(buildArtifactDir)
Run Code Online (Sandbox Code Playgroud)
更新
\n请参考此 DC 链接中的响应 - Yaml 扩展了循环步骤时出错的功能。
\n\xe2\x80\x8bYAML 在 #pythonparameter-template.yml 中有一个验证任务\n注释掉这两行,你的 YAML 将成功。此处显示的模板阻止使用任何任务。对于有特定安全要求的人来说,这可能是一个场景。
\n ${{ if eq(pair.key, \'task\') }}:\n \'${{ pair.value }}\': error\nRun Code Online (Sandbox Code Playgroud)\n您是否尝试将两个 yml 合并pythonparameter-template.yml azure-pipelines.yml在同一个文件中?不支持。
parameters:\n - name: usersteps\n type: stepList\n default: []\n steps:\n - ${{ each step in parameters.usersteps }}\n - ${{ step }}\n \nRun Code Online (Sandbox Code Playgroud)\n根据错误Directives are not supported for expressions that are embedded within a string. Directives are only supported when the entire value is an expression Unexpected value \'${{ each step in parameters.usersteps }} - ${{ step }}\'
您可能使用了错误的格式。关于格式可以参考我们的官方文档--\n模板类型及使用
\n此外,您可以使 azure-pipelines.yml 也有它自己的自定义步骤。但你需要将它们放在管道中的参数下,而不是像你使用的方式。
\nazure-pipelines.yml
\ntrigger:\n- master\n\nextends:\n template: pythonparameter-template.yml\n parameters:\n buildSteps: \n - bash: echo Test #Passes\n displayName: succeed\n - bash: echo "Test"\n displayName: succeed\n - script: echo "Script Test" \n displayName: Fail\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
4598 次 |
| 最近记录: |