-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add buildkite pipeline to build elastic-agent binary artifacts (#3046)
* Add DRA pipeline * Fix mage and go check * Force trigger * Change permissions * source bootstrap * ignore existing folder * Generate dependencies report * Split in various steps and move creds to pre-command * Fix script name * Use agent to upload artifacts * Expose env var to force publish for testing * Generalize dra-publish.sh * Use version for dependencies file * Fix dry run * Run test dra publish * Fix version * Only upload distributions * Fix glob * Only add spanshot on build * Fix permissions on downloaded artifacts * Remove test env vars * Stop calling buildkite-agent in scripts * Add vars to test * Add correct command to staging * creat local var * Create local var * Remove testing force var * Remove test vars (cherry picked from commit 30dff79) # Conflicts: # .buildkite/pipeline.elastic-agent-binary-dra.yml # .buildkite/pipeline.yml # catalog-info.yaml
- Loading branch information
1 parent
9f42f86
commit 662201a
Showing
11 changed files
with
283 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
env: | ||
DRA_PROJECT: "elastic-agent-core" | ||
DRA_ARTIFACT_SET: "agent-core" | ||
steps: | ||
- group: ":beats: DRA Elastic-Agent Core Snapshot :beats:" | ||
key: "dra-core-snapshot" | ||
if: build.branch == 'main' || build.branch =~ /^[0-9]+\.[0-9]+\$/ || build.env("RUN_SNAPSHOT") == "true" | ||
steps: | ||
- label: ":package: Build Elastic-Agent Core Snapshot" | ||
commands: | ||
- .buildkite/scripts/steps/build-agent-core.sh | ||
key: "build-dra-snapshot" | ||
artifact_paths: | ||
- "build/distributions/**/*" | ||
agents: | ||
provider: "gcp" | ||
machineType: "c2-standard-16" | ||
env: | ||
WORKFLOW: "snapshot" | ||
|
||
- wait | ||
|
||
- label: ":hammer: DRA Publish Elastic-Agent Core Snapshot" | ||
command: | | ||
buildkite-agent artifact download "build/**/*" . | ||
.buildkite/scripts/steps/dra-publish.sh | ||
key: "publish-dra-snapshot" | ||
agents: | ||
provider: "gcp" | ||
machineType: "c2-standard-16" | ||
env: | ||
WORKFLOW: "snapshot" | ||
|
||
- group: ":beats: DRA Elastic-Agent Core Staging :beats:" | ||
key: "dra-core-staging" | ||
if: build.branch =~ /^[0-9]+\.[0-9]+\$/ || build.env("RUN_STAGING") == "true" | ||
steps: | ||
- label: ":package: Build Elastic-Agent Core staging" | ||
commands: | ||
- .buildkite/scripts/steps/build-agent-core.sh | ||
key: "build-dra-staging" | ||
artifact_paths: | ||
- "build/distributions/**/*" | ||
agents: | ||
provider: "gcp" | ||
machineType: "c2-standard-16" | ||
env: | ||
WORKFLOW: "staging" | ||
|
||
- wait | ||
|
||
- label: ":hammer: DRA Publish Elastic-Agent Core staging" | ||
command: | | ||
buildkite-agent artifact download "build/**/*" . | ||
.buildkite/scripts/steps/dra-publish.sh | ||
key: "publish-dra-staging" | ||
agents: | ||
provider: "gcp" | ||
machineType: "c2-standard-16" | ||
env: | ||
WORKFLOW: "staging" | ||
|
||
notify: | ||
- slack: "#ingest-notifications" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
|
||
# this is required in order to allow the build process to override the default PWD of the BEAT_NAME. | ||
export BEAT_NAME="elastic-agent" | ||
|
||
if [[ -z "${WORKSPACE-""}" ]]; then | ||
WORKSPACE=$(git rev-parse --show-toplevel) | ||
export WORKSPACE | ||
fi | ||
|
||
# Retrieve version value - will match versions like 8.8.0 and also 8.8.0-er1 | ||
export BEAT_VERSION=`grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\-[a-zA-Z]+[0-9]+)?' ${WORKSPACE}/version/version.go` | ||
export BRANCH="${BUILDKITE_BRANCH}" | ||
|
||
# Install Go TODO: move to makefile | ||
if ! command -v go &>/dev/null; then | ||
echo "Go is not installed. Installing Go..." | ||
export GO_VERSION=`cat .go-version` | ||
curl -O https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz | ||
sudo tar -xf go$GO_VERSION.linux-amd64.tar.gz -C /usr/local | ||
mkdir -p $HOME/go/bin | ||
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin | ||
echo "Go has been installed." | ||
else | ||
echo "Go is already installed." | ||
fi | ||
|
||
# Install mage | ||
make mage |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source .buildkite/scripts/bootstrap.sh | ||
|
||
echo "+++ Build Agent artifacts" | ||
SNAPSHOT="" | ||
BEAT_VERSION_FULL=$BEAT_VERSION | ||
if [ "$WORKFLOW" == "snapshot" ]; then | ||
SNAPSHOT="true" | ||
BEAT_VERSION_FULL="${BEAT_VERSION}-SNAPSHOT" | ||
fi | ||
|
||
SNAPSHOT=$SNAPSHOT mage packageAgentCore | ||
chmod -R 777 build/distributions | ||
|
||
echo "+++ Generate dependencies report" | ||
./dev-tools/dependencies-report | ||
mkdir -p build/distributions/reports | ||
mv dependencies.csv "build/distributions/reports/dependencies-${BEAT_VERSION_FULL}.csv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
set -uo pipefail | ||
|
||
source .buildkite/scripts/bootstrap.sh | ||
|
||
# Publish DRA artifacts | ||
function run_release_manager() { | ||
echo "+++ Publishing $BUILDKITE_BRANCH ${WORKFLOW} DRA artifacts..." | ||
dry_run="" | ||
if [ "$BUILDKITE_PULL_REQUEST" != "false" ]; then | ||
dry_run="--dry-run" | ||
# force main branch on PR's or it won't execute | ||
# because the PR branch does not have a project folder in release-manager | ||
BRANCH=main | ||
fi | ||
docker run --rm \ | ||
--name release-manager \ | ||
-e VAULT_ADDR="${VAULT_ADDR_SECRET}" \ | ||
-e VAULT_ROLE_ID="${VAULT_ROLE_ID_SECRET}" \ | ||
-e VAULT_SECRET_ID="${VAULT_SECRET}" \ | ||
--mount type=bind,readonly=false,src="${PWD}",target=/artifacts \ | ||
docker.elastic.co/infra/release-manager:latest \ | ||
cli collect \ | ||
--project $DRA_PROJECT \ | ||
--branch "${BRANCH}" \ | ||
--commit "${BUILDKITE_COMMIT}" \ | ||
--workflow "${WORKFLOW}" \ | ||
--version "${BEAT_VERSION}" \ | ||
--artifact-set $DRA_ARTIFACT_SET \ | ||
$dry_run | ||
} | ||
|
||
chmod -R 777 build/distributions | ||
|
||
run_release_manager | ||
RM_EXIT_CODE=$? | ||
|
||
exit $RM_EXIT_CODE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
|
||
source .buildkite/scripts/bootstrap.sh | ||
|
||
# PACKAGE | ||
DEV=true EXTERNAL=true SNAPSHOT=true PLATFORMS=linux/amd64,linux/arm64 PACKAGES=tar.gz mage package | ||
|
||
# Run integration tests | ||
set +e | ||
SNAPSHOT=true mage integration:test | ||
TESTS_EXIT_STATUS=$? | ||
set -e | ||
|
||
# HTML report | ||
go install github.com/alexec/junit2html@latest | ||
junit2html < build/TEST-go-integration.xml > build/TEST-report.html | ||
|
||
exit $TESTS_EXIT_STATUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.