microsoft / azuredevopslabs

Learn how you can plan smartly, collaborate better, and ship faster with a set of modern development services with Azure DevOps.
https://www.azuredevopslabs.com
MIT License
806 stars 905 forks source link

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

Open vivuu1989 opened 9 months ago

vivuu1989 commented 9 months ago

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'
vivuu1989 commented 9 months ago

Any method to achieve this using AzureDevops pipeline?

surajshenoy commented 8 months ago

Hi @vivuu1989, this forum is available to discuss the concerns regarding Azuredevopslabs site and the content. Seems like your concern is not related to any of the labs. Please try finding the solution in the relevant forum.