3

Hi I am using agent pool in azure pipeline, so i have multiple agents so i want to parameterize the pool name like shown below but when i do this i get an error as (Line: 11, Col: 9): A template expression is not allowed in this context

parameters:
  - name: pool_name
    displayName: agent pool location
    type: string
    default: test-ashish

trigger:
- none

pool:
  name: ${{parameters.pool_name}}
  demands: 
  - Location -equals EASTUS2

steps:
- script: |
    echo "This job is only for testing"
    echo $()
  name: Test_Job
  displayName: Test Job
ashish
  • 273
  • 1
  • 5
  • 16
  • 1
    Check if this solves your issue: https://stackoverflow.com/questions/58698996/azure-devops-is-it-possible-to-nest-yaml-templates-inside-another-yaml-template – Biplab Sah Apr 05 '21 at 07:09
  • Great! Thanks for sharing your solution here, you could [Accept it as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), so it could help other community members who get the same issues and we could archive this thread, thanks. – Felix Apr 14 '21 at 06:54

1 Answers1

0

This issue can be solved by using the answer in this issue: Azure Devops: Is it possible to nest yaml templates inside another yaml template?.

Copyed from link: refer code:

parameters:
  buildArtifactName: "build"
  solution: ""

jobs:
- job: 'BuildSolution'
  pool:
    vmImage: ${{parameters.vmImage}}
    continueOnError: false
  variables:
    artifactName: ${{ parameters.buildArtifactName}}
  steps:
    - task: NuGetCommand@2
      displayName: 'Restore NuGet packages'
      inputs:
        restoreSolution: ${{ parameters.solutionDir }}/${{ parameters.solution }}
        configuration: ${{parameters.buildConfiguration}}
Felix
  • 1,104
  • 3
  • 6