0

这是开发者回购管道

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(行:2,列:1):意外值“名称”

我们想要控制内部版本号格式,因此不想将其保留在开发者仓库中。对此问题的任何建议

4

1 回答 1

0

不幸的是,不支持使用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)"
于 2020-07-28T05:56:26.093 回答