Skip to content

Commit

Permalink
[ci] Add elastic-agent to Windows jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
brianseeders committed May 1, 2024
1 parent 85c876d commit 60e8c22
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .buildkite/hooks/pre-command.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ set JOB_BRANCH=%BUILDKITE_BRANCH%
set GRADLE_BUILD_CACHE_USERNAME=vault read -field=username secret/ci/elastic-elasticsearch/migrated/gradle-build-cache
set GRADLE_BUILD_CACHE_PASSWORD=vault read -field=password secret/ci/elastic-elasticsearch/migrated/gradle-build-cache

start "" bash.exe .buildkite\scripts\setup-monitoring.sh

exit /b 0
37 changes: 30 additions & 7 deletions .buildkite/scripts/setup-monitoring.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,43 @@ set -euo pipefail
ELASTIC_AGENT_URL=$(vault read -field=url secret/ci/elastic-elasticsearch/elastic-agent-token)
ELASTIC_AGENT_TOKEN=$(vault read -field=token secret/ci/elastic-elasticsearch/elastic-agent-token)

if [[ ! -d /opt/elastic-agent ]]; then
sudo mkdir /opt/elastic-agent
sudo chown -R buildkite-agent:buildkite-agent /opt/elastic-agent
cd /opt/elastic-agent
ELASTIC_AGENT_DIR=/opt/elastic-agent
IS_WINDOWS=""

if uname -a | grep -q MING; then
ELASTIC_AGENT_DIR=/c/elastic-agent
IS_WINDOWS="true"

sudo() {
"$@"
}
fi

if [[ ! -d $ELASTIC_AGENT_DIR ]]; then
sudo mkdir $ELASTIC_AGENT_DIR

if [[ "$IS_WINDOWS" != "true" ]]; then
sudo chown -R buildkite-agent:buildkite-agent $ELASTIC_AGENT_DIR
fi

cd $ELASTIC_AGENT_DIR

archive=elastic-agent-8.10.1-linux-x86_64.tar.gz
if [ "$(uname -m)" = "arm64" ] || [ "$(uname -m)" = "aarch64" ]; then
if [[ "$IS_WINDOWS" == "true" ]]; then
archive=elastic-agent-8.10.1-windows-x86_64.zip
elif [ "$(uname -m)" = "arm64" ] || [ "$(uname -m)" = "aarch64" ]; then
archive=elastic-agent-8.10.1-linux-arm64.tar.gz
fi

curl -L -O "https://artifacts.elastic.co/downloads/beats/elastic-agent/$archive"

tar xzf "$archive" --directory=. --strip-components=1
if [[ "$IS_WINDOWS" == "true" ]]; then
unzip "$archive"
mv elastic-agent-*/* .
else
tar xzf "$archive" --directory=. --strip-components=1
fi
fi

cd /opt/elastic-agent
cd $ELASTIC_AGENT_DIR
sudo ./elastic-agent install -f --url="$ELASTIC_AGENT_URL" --enrollment-token="$ELASTIC_AGENT_TOKEN"

0 comments on commit 60e8c22

Please sign in to comment.