Azure-pipelines-agent: Incorrect PATH variable

Created on 5 Jun 2019  路  6Comments  路  Source: microsoft/azure-pipelines-agent

Agent Version and Platform

2.150.3 - Linux - Debian 9.7

Azure DevOps Type and Version

dev.azure.com

What's not working?

When executing bash tasks the agent doesn't pickup the proper user path.
Path returned from doing echo $PATH in a bash task : /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Expected (when doing the same from a shell as the same user as the agent) :
/usr/local/lib/npm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/lib/npm/lib/node_modules/pm2/bin/:/usr/lib/postgresql/9.6/bin
All of the above paths were added after the installation of the agent.
The agent runs as a service, and the paths were not updated after agent restart nor from machine reboot.

To fix this i had to manually update the .path file in the agent folder.

no-stale stale

Most helpful comment

All 6 comments

Ah... yes it does... not sure how i missed this.
However wouldn't it be less confusing if this was done automatically after service restart? or not store those variables on disk and instead using the current runtime values ?

Yes, please make this happen on agent restart. or more often. like every time the /etc/environment file changes.

@vtbassmatt - I believe this was done intentionally as a security measure. Do you have any recollection as to why this was done this way?

This is done for reliability/repeatability. We try not to slide the environment out from under an agent. @jtpetty I see two possible approaches here, maybe you see others:
1) Accept a flag at config time that says we want this agent to not snap its environment variables
2) Implement a signal handler so that the agent doesn't have to stop/start to pick up new variables.
The sequence would become:

./env.sh
kill -HUP <agent process ID>

If we do #2, then while a job is running, we should probably defer the update until the next job runs.

This issue has had no activity in 180 days. Please comment if it is not actually stale

Was this page helpful?
0 / 5 - 0 ratings