在扩展模板中设置名称在 azure yaml 管道中不起作用
setting up name in extend template doesn't work in azure yaml pipelines
这是开发者回购管道
resources:
repositories:
- repository: extendCheck
type: git
name: PUL/extendCheck
trigger:
- none
extends:
template: base2.yml@extendCheck
parameters:
buildSteps:
- bash: echo Test #Passes
displayName: succeed
- bash: echo "Test"
displayName: succeed
- script: echo "Script Test"
displayName: Fail
这是来自中央政策团队的 repo 的扩展模板
# File: start.yml
name: $(Date:yyyy)$(Date:.MM)$(Date:.dd)$(Rev:-r)
parameters:
- name: buildSteps # the name of the parameter is buildSteps
type: stepList # data type is StepList
default: [] # default value of buildSteps
stages:
- stage: secure_buildstage
pool:
vmImage: 'ubuntu-latest'
jobs:
- job: secure_buildjob
steps:
- script: echo This happens before code
displayName: 'Base: Pre-build'
- script: echo Building
displayName: 'Base: Build'
- ${{ each step in parameters.buildSteps }}:
- ${{ each pair in step }}:
${{ if ne(pair.key, 'script') }}:
${{ pair.key }}: ${{ pair.value }}
${{ if eq(pair.key, 'script') }}: # checks for buildStep with script
'Rejecting Script: ${{ pair.value }}': error # rejects buildStep when script is found
- script: echo This happens after code
displayName: 'Base: Signing'
当我 运行 执行此操作时,出现以下错误
/base2.yml@extendCheck (Line: 2, Col: 1): Unexpected value 'name'
我们想要控制内部版本号格式,因此不想将其保留在开发人员存储库中。
对这个问题的任何建议
很遗憾,不支持使用 name
的模板。要解决此问题,我们可以使用脚本来定义变量并使用 UpdateBuildNumber command
更新构建编号格式。例如,在 base2.yml
文件末尾添加以下任务:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
[string] $dateTime = (Get-Date -Format 'yyyyMMddTHHmmss')
Write-Host "##vso[task.setvariable variable=name]$dateTime"
- script: echo "##vso[build.updatebuildnumber]$(name)"
这是开发者回购管道
resources:
repositories:
- repository: extendCheck
type: git
name: PUL/extendCheck
trigger:
- none
extends:
template: base2.yml@extendCheck
parameters:
buildSteps:
- bash: echo Test #Passes
displayName: succeed
- bash: echo "Test"
displayName: succeed
- script: echo "Script Test"
displayName: Fail
这是来自中央政策团队的 repo 的扩展模板
# File: start.yml
name: $(Date:yyyy)$(Date:.MM)$(Date:.dd)$(Rev:-r)
parameters:
- name: buildSteps # the name of the parameter is buildSteps
type: stepList # data type is StepList
default: [] # default value of buildSteps
stages:
- stage: secure_buildstage
pool:
vmImage: 'ubuntu-latest'
jobs:
- job: secure_buildjob
steps:
- script: echo This happens before code
displayName: 'Base: Pre-build'
- script: echo Building
displayName: 'Base: Build'
- ${{ each step in parameters.buildSteps }}:
- ${{ each pair in step }}:
${{ if ne(pair.key, 'script') }}:
${{ pair.key }}: ${{ pair.value }}
${{ if eq(pair.key, 'script') }}: # checks for buildStep with script
'Rejecting Script: ${{ pair.value }}': error # rejects buildStep when script is found
- script: echo This happens after code
displayName: 'Base: Signing'
当我 运行 执行此操作时,出现以下错误
/base2.yml@extendCheck (Line: 2, Col: 1): Unexpected value 'name'
我们想要控制内部版本号格式,因此不想将其保留在开发人员存储库中。 对这个问题的任何建议
很遗憾,不支持使用 name
的模板。要解决此问题,我们可以使用脚本来定义变量并使用 UpdateBuildNumber command
更新构建编号格式。例如,在 base2.yml
文件末尾添加以下任务:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
[string] $dateTime = (Get-Date -Format 'yyyyMMddTHHmmss')
Write-Host "##vso[task.setvariable variable=name]$dateTime"
- script: echo "##vso[build.updatebuildnumber]$(name)"