Azure DevOps Agent Pool can be set either at ADO-organization-level or ADO-project-level resources. This question pertains to the latter. Consider the following scenario:
Now, consider another scenario:
Can we install and run the agent process of Pool-Proj2 on Machine M1 along with the one from Pool-proj1? In other words, will there be any impact if M1 is a member of both Pool-Proj1 and Pool-Proj2?
I suppose there shouldn't be any impact since both agents will run as two different OS processes but I can't find any documentation or conversation that advises for or against it.
TL;DR Yes, you can install and configure multiple agents for different projects and/or agent pools on the same VM.
A typical startup script for Linux or Windows build agents uses environment variables such as AZP_URL
, AZP_POOL
and others to configure the build agent.
Example:
./config.sh --unattended \
--agent "${AZP_AGENT_NAME:-$(hostname)}" \
--url "${AZP_URL}" \
--auth "PAT" \
--token $(cat "${AZP_TOKEN_FILE}") \
--pool "${AZP_POOL:-Default}" \
--work "${AZP_WORK:-_work}" \
--replace \
--acceptTeeEula & wait $!
Notes:
AZP_TOKEN_FILE
is created based on the value of AZP_TOKEN
environment variable.Each agent uses a separate folder and have its own startup script. You can hard-code some of the parameters and/or use environment variables, but considering that each agent will have different configuration you need to configure different variables for each agent.
Consider adding a prefix or suffix to the environment variables used above:
Agent name | Organization URL | Agent Pool | Token | |
---|---|---|---|---|
Agent project 1 | AZP_AGENT_NAME_P1 | AZP_URL_P1 | AZP_POOL_P1 | AZP_TOKEN_P1 |
Agent project 2 | AZP_AGENT_NAME_P2 | AZP_URL_P2 | AZP_POOL_P2 | AZP_TOKEN_P2 |
Startup script for the project 1 build agent can be changed to use the variables with P1
suffix:
./config.sh --unattended \
--agent "${AZP_AGENT_NAME_P1:-$(hostname)}" \
--url "${AZP_URL_P1}" \
--auth "PAT" \
--token $(cat "${AZP_TOKEN_FILE}") \
--pool "${AZP_POOL_P1:-Default}" \
--work "${AZP_WORK:-_work}" \
--replace \
--acceptTeeEula & wait $!
See the above links for the full startup scripts for both Windows and Linux build agents.