Skip to content

Instantly share code, notes, and snippets.

@kenotron
Last active January 6, 2020 20:59
Show Gist options
  • Save kenotron/99bd35bd1a0a3b515633a50800ba49b4 to your computer and use it in GitHub Desktop.
Save kenotron/99bd35bd1a0a3b515633a50800ba49b4 to your computer and use it in GitHub Desktop.
#!/bin/sh
browser_download_url=`curl -s https://api.github.com/repos/Microsoft/azure-pipelines-agent/releases/latest | jq -r ".assets[].browser_download_url"`
download_url=`curl -s -L ${browser_download_url} | jq -r ".[] | select(.platform==\"linux-x64\") | .downloadUrl"`
echo Downloading from $download_url
sudo -E -u agent curl -s -L $download_url --output /home/agent/agent.tar.gz
echo Fixing perms
sudo -E -u root mkdir -p /agent
sudo -E -u root mkdir -p /mnt/work
sudo -E -u root mkdir -p /mnt/yarn
sudo -E -u root chown -R agent:agent /agent
sudo -E -u root chown -R agent:agent /mnt/work
sudo -E -u root chown -R agent:agent /mnt/yarn
sudo -E -u root ln -s /mnt/yarn /usr/local/share/.cache/
cd /agent
echo Extracting agent.tar.gz
sudo -E -u agent tar -zxf /home/agent/agent.tar.gz
echo Configuring Agent
sudo -E -u agent ./config.sh --unattended --acceptteeeula --url $DEVOPS_ACCOUNT --auth PAT --token $DEVOPS_PAT --pool 'Self Host Ubuntu' --agent $(hostname) --work /mnt/work --replace
echo Install and Start Agent Service
sudo -E -u root ./svc.sh install
sudo -E -u root ./svc.sh start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment