Selbst gehostete Azure DevOps bauen Agent, das kein Tool von $ path bekommtLinux

Linux verstehen
Guest
 Selbst gehostete Azure DevOps bauen Agent, das kein Tool von $ path bekommt

Post by Guest »

Ich habe einen selbsthosteten Build -Agenten, der DOTNET -Tools und Nerdbank Git -Versioning installiert hat. Wenn ich auf den Agenten ssh und nbgv ausführe, existiert es:

Code: Select all

agent@ip-172-18-0-30:~$ which nbgv
/home/agent/.dotnet/tools/nbgv
< /code>
Und ich kann es ausführen: < /p>
agent@ip-172-18-0-30:~$ nbgv -h
Description:
nbgv v3.7.115+d31f50f4d1
Zu Beginn meiner Pipeline überprüfe ich den Build -Agent -Benutzer, den $ home env var und $ path env var und versuchen dann, NBGV < /Code>: < /p>

Code: Select all

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
fehlschlägt bei NBGV: Befehl nicht gefunden :

Code: Select all

/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.com/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
Trotz $ Home beinigen/home/agent und $ path mit $ home/.dotnet/tools und nbgv < /Code> In /home/agent/.dotnet/tools/nbgv ist es fehlschlägt, dass es NBGV nicht finden kann. Warum ist das und wie behebte ich das?

Code: Select all

#!/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.net/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

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post