Assign build configuration to agent using REST api?
Hi,
I want to assign a specific build configuration to a specific agent using the REST api.
The docs only describe on how to assign a project to an agent pool.
Is it even possible to do this?
Thanks!
Please sign in to leave a comment.
Hi,
Yes, it should be possible to do it. The reason it's not explicitly stated in the docs is because there is no direct action for it, but also not in the UI. The process is described here: https://confluence.jetbrains.com/display/TCD18/Assigning+Build+Configurations+to+Specific+Build+Agents
The UI does have the possibility to assign configurations to a specific build agent:
If you select a build agent, you can set "Run assigned configurations only" and then hit the "Assign configurations" button.
And this is what I want to do using the REST api.
Hi Jan,
thanks for pointing that out, I was in the mindset of the other approach, mentioned in the documentation and completely forgot about that one. Anyways (and I did double check this one), the situation is the same. What this action creates is it sets up a specific build requirement and assigns that requirement to the agent, so that they are matched. This can be done the same way via the REST API, by adding an agent requirement to the name of the agent that you wish to assign.
Hi,
if I understand you correctly, I just have to add the agent's name as requirement to my build configuration.
But this doesn't work:
If I set this requirement, the agent is still not allowed to run this configuration.
Or did I mistunderstand you?
Hi Jan,
that's pretty strange, I've been testing the exact same setup and it works fine on my end. If you access the agent on the UI, is it enabled to only run assigned configurations, and is in this case that not one of those?
A quick follow up, we have a request to implement it directly into the REST API here: https://youtrack.jetbrains.com/issue/TW-42286
I checked, and the build configuration with the explicit agent name requirement is not not listed as "assigned compatible configuration" in the agent's UI.
Hi Jan,
sorry, I'd like to take a step back and approach the whole situation again from a more full perspective rather than focus on the specific issue. While I mentioned that it does the same, this is not exactly true. It achieves the same results but is not exactly the same to set up an arbitrary parameter and match it on an agent or to assign the build to an agent. While it leads to the same results, and will internally be handled similarly, you cannot use the "run assigned configurations only" and set your own arbitrary parameter for TeamCity to pick it up. After reviewing my old messages I can see how they could have lead to the confusion, so I'd like to apologize for that.
Unfortunately, assigning configurations to agents cannot be done via the REST API on the assign configurations to an agent page, as already mentioned. In order to do exactly that, you will need to vote for the issue in the tracker and wait for its implementation.
In the meantime, the way to do is would be to set the agent in an agent pool and assign it exclusively to the project where your build configuration resides (isolating build configurations as much as possible in projects would help here), then do the parameter assignation method. But you will need to leave the agent to "run every build configuration" and just filter them via parameters instead.