4

I have built self-hosted ubuntu agents running in docker.

All works fine, build agent is working etc.

except everything in pipeline steps is being executed as root instead of non-root user.

E.g. When I try to execute "npm ci" and I look at my build-agent logs:

; node bin location = /usr/bin/node ; cwd = /azp/agent/_work/1/s/Core ; HOME = /root

vs logs from Microsoft hosted build-agent:

; node bin location = /usr/local/bin/node ; cwd = /home/vsts/work/1/s/Core ; HOME = /home/vsts

this gives me issues in lot of stages as running some commands as root requires different settings etc. Does anyone know how to change it from ROOT?

I tried within dockerfile and within start.sh script provided by microsoft but that did not worked. Build agent would not start at all if I would execute start.sh as docker user instead of root. Any clues? ideas?

novak100
  • 1,259
  • 1
  • 12
  • 20

1 Answers1

1

You can install your linux agent under the account to change it from root like /home/{accountname}/.

Below is the steps about how to install the linux agent under the non-root user.

Connect to linux agent by non-root user

ssh useraccount@linuxIp

Create a folder and cd the folder.

mkdir myagent && cd myagent

Download the package from the url.

wget https://vstsagentpackage.azureedge.net/agent/2.155.1/vsts-agent-linux-x64-2.155.1.tar.gz

Unzip the file.

tar xzf vsts-agent-linux-x64-2.155.1.gz

Config the linux Agent

Frank Wang-MSFT
  • 1,367
  • 6
  • 6
  • so this would potentially work if I would like to create it manually. What Im trying to do is to create automated build and deployment of build agent on a Docker within Azure DevOps, trying to follow this link: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops – novak100 Nov 19 '19 at 14:38