Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use variable or parameter in demands #21

Closed
timwebster9 opened this issue Oct 20, 2018 · 3 comments
Closed

Use variable or parameter in demands #21

timwebster9 opened this issue Oct 20, 2018 · 3 comments

Comments

@timwebster9
Copy link

Is it possible to use a variable or parameters in agent pool demands? Something like this:

variables:
  projectName:my-vsts-project
  agentName: '$(projectName)-$(Build.BuildId)'

jobs:
- job: JavaBuild
  dependsOn: LaunchAgent
  pool:
    name: 'mgmt-aks-sandbox'
    demands:
    - agent.name -equals $(agentName)

It doesn't seem to work, as I end up getting like this:

##[Error 1]
No agent found in pool mgmt-aks-sandbox which satisfies the specified demands:
     agent.name -equals $(projectName)-$(Build.BuildId)
     java
     Agent.Version -gtVersion 2.140.2 

I've also tried with parameters and template expressions, and those don't work either:

##[Error 1]
No agent found in pool mgmt-aks-sandbox which satisfies the specified demands:
     agent.name -equals ${{ parameters.agentName }}
     java
     Agent.Version -gtVersion 2.140.2 

It looks like this guy managed to do it via the UI (see comments at the end), but is there a way to do it in YAML?
https://www.noelbundick.com/posts/serverless-vsts-build-agents-with-azure-container-instances/

@timwebster9
Copy link
Author

Update: It works if you don't use the top level variable like I was doing above, but rather do this instead:

  pool:
    name: 'mgmt-aks-sandbox'
    demands:
    - agent.name -equals $(projectName)-$(Build.BuildId)

This can be closed unless anyone has any other comments...

@mcgov
Copy link

mcgov commented May 29, 2019

Ah, this is due to nested variable resolution; or the lack thereof. Agent name won't resolve to the value you think it is, in the original it will end up as $(projectName)-$(Build.BuildId)

This still helped me, thank you for raising this issue!

@stale
Copy link

stale bot commented Apr 25, 2020

In order to consolidate to fewer feedback channels, we've moved suggestions and issue reporting to Developer Community. Sorry for any confusion resulting from this move.

@stale stale bot closed this as completed Apr 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants