How to pick directory Paths based on Build Agent Name in AzureDevops task

27 Views Asked by At

We have a requirement in Azuredevops task to pick the Tasks filesystem path (gradleHome), based on the agent.name as we have different kind of agents in the same pool.

I tried, below solution, but didn't work. It's not picking the gradleHome Pathas per the agent picked.

- task: Gradle@2
  displayName: 'Clean Project'
  inputs:
   workingDirectory: 'xxxx'
   gradleWrapperFile: '$(System.DefaultWorkingDirectory)/gradlew'
   javaHomeOption: 'JDKVersion'
   jdkVersionOption: '1.11'
   ${{ if startsWith(variables['Agent.Name'], 'mypool1')}}:
     tasks: 'clean <Commands> -Dgradle.user.home=/opt/gradle-8.0.2'
   ${{ if notIn(variables['Agent.Name'], 'azdevops-android-scaledjob')}}:
     tasks: 'clean <Commands> -Dgradle.user.home=/data/gradle'
0

There are 0 best solutions below