0

ステージ レベルで変数グループを定義し、テンプレートを介して以下のジョブでアクセスする方法を見つけようとしていますか? どうすればこれを行うことができますか?

# Template file getchangedfilesandvariables.yaml
parameters:
  - name: "previouscommitid"
    type: string

    
steps:
  - task: PowerShell@2
    displayName: 'Get the changed files'
    name: CommitIds
    inputs:
      targetType: 'filePath'
      filePath: '$(Build.SourcesDirectory)\AzureDevOpsPipelines\Get-COChangedfiles.ps1'
      arguments: >
        -old_commit_id ${{ previouscommitid }}

  - task: PowerShell@2
    name: PassOutput
    displayName: 'Getting Variables for Packaging'
    inputs:
        targetType: 'filepath'
        filepath: '$(System.DefaultWorkingDirectory)\AzureDevOpsPipelines\Get-COADOvariables.ps1'

以下は私のyamlファイルです。

trigger: none
name: $(BuildID)

variables:
  
  system.debug: true
  CodeSigningCertThumbprint: "somethumbprint"
  # Triggering builds on a branch itself.
  ${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/') }}:
    branchName: $[ replace(variables['Build.SourceBranch'], 'refs/heads/', '') ]
  # Triggering builds from a Pull Request.
  ${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
    branchName: $[ replace(variables['System.PullRequest.SourceBranch'], 'refs/heads/', '') ]

## it will create pipeline package and it will push it private or public feed artifacts
stages:
  - stage: Stage1
    variables:
    - group: Cloudops
    - name: oldcommitid
      value: $[variables.lastcommitid]

    jobs:
    - job: IdentifyChangedFilesAndGetADOVariables
      

      pool:
        name: OnPrem

      workspace:
        clean: all # Ensure the agent's directories are wiped clean before building.

      steps:
      - powershell: |
          [System.Version]$PlatformVersion = ((Get-Content "$(Build.SourcesDirectory)\AzureDevOpsPipelines\PlatformVersion.json") | ConvertFrom-Json).PlatformVersion
          Write-Output "The repository's PlatformVersion is: $($PlatformVersion.ToString())"
          $NewPackageVersion = New-Object -TypeName "System.Version" -ArgumentList @($PlatformVersion.Major, $PlatformVersion.Minor, $(Build.BuildId))

          Write-Output "This run's package version is $($NewPackageVersion.ToString())"
          echo "##vso[task.setvariable variable=NewPackageVersion]$($NewPackageVersion.ToString())"
          echo "##vso[task.setvariable variable=commitidold;isOutput=true]$(oldcommitid)" 
        displayName: 'Define package version.'
        name: commitidorpackageversion
        errorActionPreference: stop

      - template: getchangedfilesandvariables.yaml
        parameters: 
          previouscommitid:
            - $(commitidorpackageversion.commitidold)
           # - $(oldcommitid)

コードの最後の 2 行目でエラーが発生します。

/AzureDevOpsPipelines/azure-pipelines.yml (行: 49、列: 13): 'previouscommitid' パラメーターは有効な文字列ではありません。

さまざまな組み合わせを試しましたが、まだエラーが発生しています。

何か案は?

4

2 に答える 2