admin管理员组文章数量:1302242
I have a self hosted build agent, which has dotnet tools and nerdbank git versioning installed. If I SSH onto the agent and run nbgv
, it exists:
agent@ip-172-18-0-30:~$ which nbgv
/home/agent/.dotnet/tools/nbgv
And I can run it:
agent@ip-172-18-0-30:~$ nbgv -h
Description:
nbgv v3.7.115+d31f50f4d1
At the start of my pipeline, I am checking the build agent user, the $HOME
env var and $PATH
env var then trying to run nbgv
:
steps:
- checkout: self
fetchDepth: 0
persistCredentials: true
- script: |
echo "Current user: $(whoami)"
echo "HOME: $HOME"
echo "PATH: $PATH"
ls -la $HOME/.dotnet/tools
dotnet tool list --global
nbgv get-version
However it is failing with nbgv: command not found
:
/usr/bin/bash --noprofile --norc /home/agent/myagent/_work/_temp/976f3776-1157-4b41-a83c-b9a2e0d5e1da.sh
Current user: agent
HOME: /home/agent
PATH: $HOME/.local/bin:/opt/pipx_bin:$HOME/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
total 84
drwxr-xr-x 3 agent agent 4096 Feb 10 13:36 .
drwxr-xr-x 3 agent agent 4096 Feb 10 13:36 ..
drwxr-xr-x 4 agent agent 4096 Feb 10 13:36 .store
-rwxr-xr-x 1 agent agent 72352 Feb 10 13:36 nbgv
Welcome to .NET 8.0!
---------------------
SDK Version: 8.0.405
Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET CLI Tools telemetry:
----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, view the instructions:
----------------
Write your first app:
Find out what's new:
Explore documentation:
Report issues and find source on GitHub:
Use 'dotnet --help' to see available commands or visit:
--------------------------------------------------------------------------------------
Package Id Version Commands
-------------------------------------
nbgv 3.7.115 nbgv
/home/agent/myagent/_work/_temp/976f3776-1157-4b41-a83c-b9a2e0d5e1da.sh: line 6: nbgv: command not found
So despite $HOME
being /home/agent
and $PATH
having $HOME/.dotnet/tools
and nbgv
being in /home/agent/.dotnet/tools/nbgv
, it is failing saying it cant find nbgv
. Why is this and how do I fix it?
For reference, my user data script is:
#!/bin/bash
AGENT_USER="agent"
AGENT_HOME="/home/$AGENT_USER"
useradd -m -s /bin/bash $AGENT_USER
export VSTS_AGENT_INPUT_URL=${url}
export VSTS_AGENT_INPUT_AUTH=pat
export VSTS_AGENT_INPUT_TOKEN=${token}
export VSTS_AGENT_INPUT_POOL=${pool}
echo "export VSTS_AGENT_INPUT_URL=${url}" >> $AGENT_HOME/.bashrc
echo "export VSTS_AGENT_INPUT_AUTH=pat" >> $AGENT_HOME/.bashrc
echo "export VSTS_AGENT_INPUT_TOKEN=${token}" >> $AGENT_HOME/.bashrc
echo "export VSTS_AGENT_INPUT_POOL=${pool}" >> $AGENT_HOME/.bashrc
chown -R $AGENT_USER:$AGENT_USER $AGENT_HOME
cd $AGENT_HOME
wget .248.0/vsts-agent-linux-x64-4.248.0.tar.gz
mkdir myagent && cd myagent
tar zxvf ../vsts-agent-linux-x64-4.248.0.tar.gz
./bin/installdependencies.sh
chown -R $AGENT_USER:$AGENT_USER .
su $AGENT_USER -c './config.sh --unattended'
echo "HOME=$AGENT_HOME" >> .env
./svc.sh install $AGENT_USER
usermod -aG docker $AGENT_USER
./svc.sh start
mkdir -p $AGENT_HOME/myagent/_work
chown -R $AGENT_USER:$AGENT_USER $AGENT_HOME/myagent/_work
I have a self hosted build agent, which has dotnet tools and nerdbank git versioning installed. If I SSH onto the agent and run nbgv
, it exists:
agent@ip-172-18-0-30:~$ which nbgv
/home/agent/.dotnet/tools/nbgv
And I can run it:
agent@ip-172-18-0-30:~$ nbgv -h
Description:
nbgv v3.7.115+d31f50f4d1
At the start of my pipeline, I am checking the build agent user, the $HOME
env var and $PATH
env var then trying to run nbgv
:
steps:
- checkout: self
fetchDepth: 0
persistCredentials: true
- script: |
echo "Current user: $(whoami)"
echo "HOME: $HOME"
echo "PATH: $PATH"
ls -la $HOME/.dotnet/tools
dotnet tool list --global
nbgv get-version
However it is failing with nbgv: command not found
:
/usr/bin/bash --noprofile --norc /home/agent/myagent/_work/_temp/976f3776-1157-4b41-a83c-b9a2e0d5e1da.sh
Current user: agent
HOME: /home/agent
PATH: $HOME/.local/bin:/opt/pipx_bin:$HOME/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
total 84
drwxr-xr-x 3 agent agent 4096 Feb 10 13:36 .
drwxr-xr-x 3 agent agent 4096 Feb 10 13:36 ..
drwxr-xr-x 4 agent agent 4096 Feb 10 13:36 .store
-rwxr-xr-x 1 agent agent 72352 Feb 10 13:36 nbgv
Welcome to .NET 8.0!
---------------------
SDK Version: 8.0.405
Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, view the instructions: https://aka.ms/dotnet-https-linux
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Package Id Version Commands
-------------------------------------
nbgv 3.7.115 nbgv
/home/agent/myagent/_work/_temp/976f3776-1157-4b41-a83c-b9a2e0d5e1da.sh: line 6: nbgv: command not found
So despite $HOME
being /home/agent
and $PATH
having $HOME/.dotnet/tools
and nbgv
being in /home/agent/.dotnet/tools/nbgv
, it is failing saying it cant find nbgv
. Why is this and how do I fix it?
For reference, my user data script is:
#!/bin/bash
AGENT_USER="agent"
AGENT_HOME="/home/$AGENT_USER"
useradd -m -s /bin/bash $AGENT_USER
export VSTS_AGENT_INPUT_URL=${url}
export VSTS_AGENT_INPUT_AUTH=pat
export VSTS_AGENT_INPUT_TOKEN=${token}
export VSTS_AGENT_INPUT_POOL=${pool}
echo "export VSTS_AGENT_INPUT_URL=${url}" >> $AGENT_HOME/.bashrc
echo "export VSTS_AGENT_INPUT_AUTH=pat" >> $AGENT_HOME/.bashrc
echo "export VSTS_AGENT_INPUT_TOKEN=${token}" >> $AGENT_HOME/.bashrc
echo "export VSTS_AGENT_INPUT_POOL=${pool}" >> $AGENT_HOME/.bashrc
chown -R $AGENT_USER:$AGENT_USER $AGENT_HOME
cd $AGENT_HOME
wget https://vstsagentpackage.azureedge/agent/4.248.0/vsts-agent-linux-x64-4.248.0.tar.gz
mkdir myagent && cd myagent
tar zxvf ../vsts-agent-linux-x64-4.248.0.tar.gz
./bin/installdependencies.sh
chown -R $AGENT_USER:$AGENT_USER .
su $AGENT_USER -c './config.sh --unattended'
echo "HOME=$AGENT_HOME" >> .env
./svc.sh install $AGENT_USER
usermod -aG docker $AGENT_USER
./svc.sh start
mkdir -p $AGENT_HOME/myagent/_work
chown -R $AGENT_USER:$AGENT_USER $AGENT_HOME/myagent/_work
Share
asked Feb 10 at 21:22
Tom McLeanTom McLean
6,3691 gold badge21 silver badges49 bronze badges
2
|
1 Answer
Reset to default 1Based on your description, I could reproduce the issue when I installed nbgv
after I setup the self-hosted pipeline agent.
As suggested in this document, we need to update environment variables after installing new software.
./env.sh
sudo ./svc.sh stop
sudo ./svc.sh start
本文标签: linuxSelf hosted azure devops build agent not getting tool from PATHStack Overflow
版权声明:本文标题:linux - Self hosted azure devops build agent not getting tool from $PATH - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741689724a2392650.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
$HOME
, not literal dollarsign-H-O-M-E. (This differs from Windows where the PATH registry entry has a special type, REG_EXPAND_SZ, which does cause such 'recursive' expansion when it is read from the registry.) Similarly~
in PATH isn't expanded, but it usually is and must be in a shell command that uses it to set PATH. Alternatively you could use e.g../nbgv
to specify the location of nbgv so PATH isn't needed. – dave_thompson_085 Commented Feb 10 at 22:22