Skip to content

Commit aaa226f

Browse files
authored
Updated to latest install script (#14)
Updated installation script to include AzureCLI setup Updated readme
1 parent aeacd76 commit aaa226f

File tree

4 files changed

+48
-42
lines changed

4 files changed

+48
-42
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
[![Docker Image](https://img.shields.io/docker/image-size/emberstack/azure-pipelines-agent/latest?style=flat-square)](https://hub.docker.com/r/emberstack/azure-pipelines-agent)
77
[![Docker Pulls](https://img.shields.io/docker/pulls/emberstack/azure-pipelines-agent.svg?style=flat-square)](https://hub.docker.com/r/emberstack/azure-pipelines-agent)
88
[![license](https://img.shields.io/github/license/emberstack/docker-azure-pipelines-agent.svg?style=flat-square)](LICENSE)
9-
[![slack](https://img.shields.io/badge/join-emberstack%20on%20Slack-gray.svg?style=flat-square&longCache=true&logo=slack&colorB=green)](https://join.slack.com/t/emberstack/shared_invite/zt-8qyutopg-9ghwTq3OnHSm2tY9Sk5ULA)
109

1110
> Supports `amd64`, `arm` and `arm64`
1211

azure-pipelines.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: $(version).$(Rev:r)
22

33
variables:
4-
version: 2.0
5-
buildConfiguration: "Release"
4+
version: 2.1
65
imageRepository: "emberstack/azure-pipelines-agent"
76
DOCKER_CLI_EXPERIMENTAL: "enabled"
87

src/docker/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ RUN apt-get update \
1616
libicu60 \
1717
libunwind8 \
1818
netcat \
19+
libssl1.0 \
1920
zip \
20-
unzip
21+
unzip \
22+
&& rm -rf /var/lib/apt/lists/*
23+
24+
RUN curl -LsS https://aka.ms/InstallAzureCLIDeb | bash \
25+
&& rm -rf /var/lib/apt/lists/*
2126

2227
WORKDIR /azp
2328

src/docker/start.sh

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,43 @@ if [ -n "$AZP_WORK" ]; then
3535
mkdir -p "$AZP_WORK"
3636
fi
3737

38-
rm -rf /azp/agent
39-
mkdir /azp/agent
40-
cd /azp/agent
38+
39+
40+
echo "Setup - Determining matching Azure Pipelines agent..."
41+
AZP_AGENT_RESPONSE=$(curl -LsS \
42+
-u user:$(cat "$AZP_TOKEN_FILE") \
43+
-H 'Accept:application/json' \
44+
"$AZP_URL/_apis/distributedtask/packages/agent?platform=$PLATFORM")
45+
if echo "$AZP_AGENT_RESPONSE" | jq . >/dev/null 2>&1; then
46+
AZP_AGENTPACKAGE_URL=$(echo "$AZP_AGENT_RESPONSE" \
47+
| jq -r '.value | map([.version.major,.version.minor,.version.patch,.downloadUrl]) | sort | .[length-1] | .[3]')
48+
fi
49+
if [ -z "$AZP_AGENTPACKAGE_URL" -o "$AZP_AGENTPACKAGE_URL" == "null" ]; then
50+
echo 1>&2 "Setup - Could not determine a matching Azure Pipelines agent. Check that account '$AZP_URL' is correct and the token is valid for that account"
51+
exit 1
52+
fi
53+
echo "Setup - Latest agent package will be downloaded from $AZP_AGENTPACKAGE_URL"
54+
echo "Setup - Downloading and unpacking Azure Pipelines agent..."
55+
curl -LsS $AZP_AGENTPACKAGE_URL | tar -xz & wait $!
56+
echo "Setup - Completed download and unpack"
57+
58+
59+
4160

4261
export AGENT_ALLOW_RUNASROOT="1"
4362

4463
cleanup() {
4564
if [ -e config.sh ]; then
4665
print_header "Cleanup. Removing Azure Pipelines agent..."
4766

48-
./config.sh remove --unattended \
49-
--auth PAT \
50-
--token $(cat "$AZP_TOKEN_FILE")
67+
# If the agent has some running jobs, the configuration removal process will fail.
68+
# So, give it some time to finish the job.
69+
while true; do
70+
./config.sh remove --unattended --auth PAT --token $(cat "$AZP_TOKEN_FILE") && break
71+
72+
echo "Retrying in 30 seconds..."
73+
sleep 30
74+
done
5175
fi
5276
}
5377

@@ -60,36 +84,9 @@ print_header() {
6084
# Let the agent ignore the token env variables
6185
export VSO_AGENT_IGNORE=AZP_TOKEN,AZP_TOKEN_FILE
6286

63-
print_header "1. Determining matching Azure Pipelines agent..."
64-
65-
AZP_AGENT_RESPONSE=$(curl -LsS \
66-
-u user:$(cat "$AZP_TOKEN_FILE") \
67-
-H 'Accept:application/json;api-version=3.0-preview' \
68-
"$AZP_URL/_apis/distributedtask/packages/agent?platform=$PLATFORM")
69-
70-
if echo "$AZP_AGENT_RESPONSE" | jq . >/dev/null 2>&1; then
71-
AZP_AGENTPACKAGE_URL=$(echo "$AZP_AGENT_RESPONSE" \
72-
| jq -r '.value | map([.version.major,.version.minor,.version.patch,.downloadUrl]) | sort | .[length-1] | .[3]')
73-
fi
74-
75-
if [ -z "$AZP_AGENTPACKAGE_URL" -o "$AZP_AGENTPACKAGE_URL" == "null" ]; then
76-
echo 1>&2 "error: could not determine a matching Azure Pipelines agent - check that account '$AZP_URL' is correct and the token is valid for that account"
77-
exit 1
78-
fi
79-
80-
print_header "2. Downloading and installing Azure Pipelines agent..."
81-
print_header "Agent package: $AZP_AGENTPACKAGE_URL"
82-
83-
curl -LsS $AZP_AGENTPACKAGE_URL | tar -xz & wait $!
84-
8587
source ./env.sh
8688

87-
trap 'cleanup; exit 130' INT
88-
trap 'cleanup; exit 143' TERM
89-
90-
print_header "3. Configuring Azure Pipelines agent..."
91-
92-
./bin/installdependencies.sh
89+
print_header "1. Configuring Azure Pipelines agent..."
9390

9491
./config.sh --unattended \
9592
--agent "${AZP_AGENT_NAME:-$(hostname)}" \
@@ -101,8 +98,14 @@ print_header "3. Configuring Azure Pipelines agent..."
10198
--replace \
10299
--acceptTeeEula & wait $!
103100

104-
print_header "4. Running Azure Pipelines agent..."
101+
print_header "2. Running Azure Pipelines agent..."
102+
103+
trap 'cleanup; exit 0' EXIT
104+
trap 'cleanup; exit 130' INT
105+
trap 'cleanup; exit 143' TERM
106+
107+
# To be aware of TERM and INT signals call run.sh
108+
# Running it with the --once flag at the end will shut down the agent after the build is executed
109+
./run.sh "$@" &
105110

106-
# `exec` the node runtime so it's aware of TERM and INT signals
107-
# AgentService.js understands how to handle agent self-update and restart
108-
exec ./externals/node/bin/node ./bin/AgentService.js interactive
111+
wait $!

0 commit comments

Comments
 (0)