Skip to content

Commit 45badd9

Browse files
authoredMay 23, 2023
Buildkite migration (#944)
1 parent 49da7dd commit 45badd9

20 files changed

+121
-440
lines changed
 

‎.buildkite/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Buildkite
2+
3+
This README provides an overview of the Buildkite pipeline used to automate the build and publish process for Cloudbeat artifacts.
4+
5+
## Artifacts
6+
7+
The pipeline generates the following artifacts:
8+
9+
- **dependencies-CLOUDBEAT_VERSION-WORKFLOW.csv**: This CSV file contains a list of dependencies for the specific Cloudbeat version being built. It helps track build dependencies.
10+
11+
- **cloudbeat-CLOUDBEAT_VERSION-WORKFLOW-linux-ARCH.tar.gz**: This tarball includes the Cloudbeat binary and its corresponding csp-policies archive. The supported architectures for the artifacts are amd64 and arm64.
12+
13+
## Triggering the Pipeline
14+
15+
The pipeline is triggered in the following scenarios:
16+
17+
- **Snapshot Builds**: A snapshot build is triggered when a pull request (PR) is merged into the 'main' branch or a version-specific branch. Additionally, if the environment variable RUN_RELEASE is set to "true", a snapshot build is also triggered.
18+
19+
- **Staging Builds**: A staging build is triggered when a PR is merged into a version-specific branch or when the environment variable RUN_RELEASE is set to "true". Staging builds are typically used for a release build candidate.
20+
21+
After a successful build, the pipeline publishes the generated artifacts to the Google Cloud Storage (GCS) bucket named [elastic-artifacts-snapshot/cloudbeat](https://console.cloud.google.com/storage/browser/elastic-artifacts-snapshot/cloudbeat). You can access the published artifacts in this bucket.
22+
23+
## Pipeline Configuration
24+
25+
To view the pipeline and its configuration, click [here](https://buildkite.com/elastic/cloudbeat).

‎.buildkite/pipeline.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
env:
2+
BRANCH: "${BUILDKITE_BRANCH}"
3+
agents:
4+
provider: "gcp" # needed for running docker commands
5+
6+
steps:
7+
- label: ":package: Package Cloudbeat - Snapshot"
8+
if: build.branch == 'main' || build.branch =~ /^[0-9]+\.[0-9]+\$/ || build.env("RUN_RELEASE") == "true"
9+
env:
10+
WORKFLOW: "snapshot"
11+
key: "package-snapshot"
12+
command: "./.buildkite/scripts/package.sh"
13+
artifact_paths: "build/distributions/*"
14+
15+
- label: ":rocket: Publishing Snapshot DRA artifacts"
16+
if: build.branch == 'main' || build.branch =~ /^[0-9]+\.[0-9]+\$/ || build.env("RUN_RELEASE") == "true"
17+
depends_on: "package-snapshot"
18+
command: "./.buildkite/scripts/publish.sh"
19+
env:
20+
WORKFLOW: "snapshot"
21+
22+
- label: ":package: Package Cloudbeat - Staging"
23+
if: build.branch =~ /^[0-9]+\.[0-9]+\$/ || build.env("RUN_RELEASE") == "true"
24+
env:
25+
WORKFLOW: "staging"
26+
key: "package-staging"
27+
command: "./.buildkite/scripts/package.sh"
28+
artifact_paths: "build/distributions/*"
29+
30+
- label: ":rocket: Publishing Staging DRA artifacts"
31+
if: build.branch =~ /^[0-9]+\.[0-9]+\$/ || build.env("RUN_RELEASE") == "true"
32+
depends_on: "package-staging"
33+
command: "./.buildkite/scripts/publish.sh"
34+
env:
35+
WORKFLOW: "staging"

‎.ci/scripts/package.sh ‎.buildkite/scripts/package.sh

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
#!/usr/bin/env bash
22
set -euox pipefail
33

4-
# linux/amd64 is in the default list already, set here
5-
# to prevent jenkins_release.sh from adding more PLATFORMS
64
export PLATFORMS="linux/amd64,linux/arm64"
75
export TYPES="tar.gz"
86

9-
make activate-hermit
10-
7+
source ./bin/activate-hermit
118
if [ $WORKFLOW = "staging" ] ; then
129
make release-manager-release
1310
else

‎.buildkite/scripts/publish.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
# Allow other users write access to create checksum files
4+
5+
# The "branch" here selects which "$BRANCH.gradle" file of release manager is used
6+
export VERSION=$(grep defaultBeatVersion version/version.go | cut -f2 -d "\"")
7+
MAJOR=$(echo $VERSION | awk -F. '{ print $1 }')
8+
MINOR=$(echo $VERSION | awk -F. '{ print $2 }')
9+
if [ -n "$(git ls-remote --heads origin $MAJOR.$MINOR)" ] ; then
10+
BRANCH=$MAJOR.$MINOR
11+
elif [ -n "$(git ls-remote --heads origin $MAJOR.x)" ] ; then
12+
BRANCH=$MAJOR.x
13+
else
14+
BRANCH=main
15+
fi
16+
17+
# Download artifacts from other stages
18+
echo "Downloading artifacts..."
19+
buildkite-agent artifact download "build/distributions/*" "." --step package-"${WORKFLOW}"
20+
chmod -R 777 build/distributions
21+
22+
# Shared secret path containing the dra creds for project teams
23+
DRA_CREDS=$(vault kv get -field=data -format=json kv/ci-shared/release/dra-role)
24+
25+
# Run release-manager
26+
echo "Running release-manager container..."
27+
IMAGE="docker.elastic.co/infra/release-manager:latest"
28+
docker run --rm \
29+
--name release-manager \
30+
-e VAULT_ADDR=$(echo $DRA_CREDS | jq -r '.vault_addr') \
31+
-e VAULT_ROLE_ID=$(echo $DRA_CREDS | jq -r '.role_id') \
32+
-e VAULT_SECRET_ID=$(echo $DRA_CREDS | jq -r '.secret_id') \
33+
--mount type=bind,readonly=false,src="${PWD}",target=/artifacts \
34+
"$IMAGE" \
35+
cli collect \
36+
--project cloudbeat \
37+
--branch "${BRANCH}" \
38+
--commit "${BUILDKITE_COMMIT}" \
39+
--workflow "${WORKFLOW}" \
40+
--version "${VERSION}" \
41+
--artifact-set main \

‎.ci/jobs/cloudbeat-mbp.yml

-52
This file was deleted.

‎.ci/jobs/cloudbeat.yml

-5
This file was deleted.

‎.ci/jobs/defaults.yml

-13
This file was deleted.

‎.ci/scripts/intake.sh

-15
This file was deleted.

‎.ci/scripts/integration-tests.sh

-39
This file was deleted.

‎.ci/scripts/rm-docker.sh

-33
This file was deleted.

‎.ci/scripts/unit-test.sh

-9
This file was deleted.

‎.editorconfig

-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ indent_style = tab
2929
[*.mk]
3030
indent_style = tab
3131

32-
[Jenkinsfile]
33-
indent_size = 2
34-
indent_style = space
35-
3632
[Vagrantfile]
3733
indent_size = 2
3834
indent_style = space

‎.github/CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Infra & ops related
55
/deploy/ @elastic/csp-ops
66
.ci/ @elastic/csp-ops
7-
Jenkinsfile @elastic/csp-ops
7+
.buildkite/ @elastic/csp-ops
88

99
# Automation tests
1010
/tests/ @elastic/csp-automation

‎Jenkinsfile

-216
This file was deleted.

‎Makefile

+14-19
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@
44
CI_ELASTIC_AGENT_DOCKER_TAG?=8.7.0-SNAPSHOT
55
CI_ELASTIC_AGENT_DOCKER_IMAGE?=704479110758.dkr.ecr.eu-west-2.amazonaws.com/elastic-agent
66

7-
# Ensure the Go version in .go_version is installed and used.
8-
GOROOT?=$(shell ./scripts/make/run_with_go_ver go env GOROOT)
9-
GO:=$(GOROOT)/bin/go
10-
export PATH:=$(GOROOT)/bin:$(PATH)
11-
127
# By default we run tests with verbose output. This may be overridden, e.g.
138
# scripts may set GOTESTFLAGS=-json to format test output for processing.
149
GOTESTFLAGS?=-v
1510

16-
GOOSBUILD:=./build/$(shell $(GO) env GOOS)
11+
GOOSBUILD:=./build/$(shell go env GOOS)
1712
APPROVALS=$(GOOSBUILD)/approvals
1813
GENPACKAGE=$(GOOSBUILD)/genpackage
1914
GOIMPORTS=$(GOOSBUILD)/goimports
@@ -24,7 +19,7 @@ STATICCHECK=$(GOOSBUILD)/staticcheck
2419
ELASTICPACKAGE=$(GOOSBUILD)/elastic-package
2520

2621
PYTHON_ENV?=.
27-
PYTHON_BIN:=$(PYTHON_ENV)/build/ve/$(shell $(GO) env GOOS)/bin
22+
PYTHON_BIN:=$(PYTHON_ENV)/build/ve/$(shell go env GOOS)/bin
2823
PYTHON=$(PYTHON_BIN)/python
2924

3025
CLOUDBEAT_VERSION=$(shell grep defaultBeatVersion version/version.go | cut -d'=' -f2 | tr -d '" ')
@@ -67,15 +62,15 @@ cloudbeat:
6762

6863
.PHONY: test
6964
test:
70-
$(GO) test $(GOTESTFLAGS) ./...
65+
go test $(GOTESTFLAGS) ./...
7166

7267
.PHONY:
7368
clean:
7469
mage clean
7570

7671
.PHONY: PackageAgent
7772
PackageAgent:
78-
SNAPSHOT=TRUE PLATFORMS=linux/$(shell $(GO) env GOARCH) TYPES=tar.gz mage -v $@
73+
SNAPSHOT=TRUE PLATFORMS=linux/$(shell go env GOARCH) TYPES=tar.gz mage -v $@
7974

8075
# elastic_agent_docker_image builds the Cloud Elastic Agent image
8176
# with the local APM Server binary injected. The image will be based
@@ -108,7 +103,7 @@ check: check-fmt check-headers
108103

109104
.PHONY: bench
110105
bench:
111-
@$(GO) test -benchmem -run=XXX -benchtime=100ms -bench='.*' ./...
106+
@go test -benchmem -run=XXX -benchtime=100ms -bench='.*' ./...
112107

113108
##############################################################################
114109
# Rules for updating config files, etc.
@@ -123,7 +118,7 @@ config:
123118

124119
.PHONY: go-generate
125120
go-generate:
126-
@$(GO) generate .
121+
@go generate .
127122

128123
notice: NOTICE.txt
129124
NOTICE.txt: $(PYTHON) go.mod utils/go.mod
@@ -162,7 +157,7 @@ update-beats-docs: $(PYTHON)
162157
# Linting, style-checking, license header checks, etc.
163158
##############################################################################
164159

165-
GOLINT_TARGETS?=$(shell $(GO) list ./...)
160+
GOLINT_TARGETS?=$(shell go list ./...)
166161
GOLINT_UPSTREAM?=origin/main
167162
REVIEWDOG_FLAGS?=-conf=reviewdog.yml -f=golint -diff="git diff $(GOLINT_UPSTREAM)"
168163
GOLINT_COMMAND=$(GOLINT) ${GOLINT_TARGETS} | grep -v "should have comment" | $(REVIEWDOG) $(REVIEWDOG_FLAGS)
@@ -209,22 +204,22 @@ autopep8: $(PYTHON_BIN)
209204
##############################################################################
210205

211206
$(GOLINT): go.mod
212-
$(GO) build -o $@ golang.org/x/lint/golint
207+
go build -o $@ golang.org/x/lint/golint
213208

214209
$(GOIMPORTS): go.mod
215-
$(GO) build -o $@ golang.org/x/utils/cmd/goimports
210+
go build -o $@ golang.org/x/utils/cmd/goimports
216211

217212
$(STATICCHECK): utils/go.mod
218-
$(GO) build -o $@ -modfile=$< honnef.co/go/utils/cmd/staticcheck
213+
go build -o $@ -modfile=$< honnef.co/go/utils/cmd/staticcheck
219214

220215
$(GOLICENSER): go.mod
221-
$(GO) build -o $@ -modfile=$< github.com/elastic/go-licenser
216+
go build -o $@ -modfile=$< github.com/elastic/go-licenser
222217

223218
$(REVIEWDOG): utils/go.mod
224-
$(GO) build -o $@ -modfile=$< github.com/reviewdog/reviewdog/cmd/reviewdog
219+
go build -o $@ -modfile=$< github.com/reviewdog/reviewdog/cmd/reviewdog
225220

226221
$(ELASTICPACKAGE): utils/go.mod
227-
$(GO) build -o $@ -modfile=$< -ldflags '-X github.com/elastic/elastic-package/internal/version.CommitHash=anything' github.com/elastic/elastic-package
222+
go build -o $@ -modfile=$< -ldflags '-X github.com/elastic/elastic-package/internal/version.CommitHash=anything' github.com/elastic/elastic-package
228223

229224
$(PYTHON): $(PYTHON_BIN)
230225
$(PYTHON_BIN): $(PYTHON_BIN)/activate
@@ -234,7 +229,7 @@ $(PYTHON_BIN)/activate:
234229

235230
.PHONY: $(APPROVALS)
236231
$(APPROVALS):
237-
@$(GO) build -o $@ github.com/elastic/cloudbeat/approvaltest/cmd/check-approvals
232+
@go build -o $@ github.com/elastic/cloudbeat/approvaltest/cmd/check-approvals
238233

239234
##############################################################################
240235
# Release manager.

‎bin/hermit.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
env = {
2-
"CLOUDBEAT_VERSION": "8.8.0",
2+
"CLOUDBEAT_VERSION": "8.9.0",
33
"ELK_VERSION": "${CLOUDBEAT_VERSION}-SNAPSHOT",
44
}

‎justfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ elastic-stack-down:
132132
elastic-package stack down
133133

134134
elastic-stack-connect-kind kind='kind-multi':
135-
./.ci/scripts/connect_kind.sh {{kind}}
135+
./scripts/connect_kind.sh {{kind}}
136136

137137
elastic-stack-disconnect-kind kind='kind-multi':
138-
./.ci/scripts/connect_kind.sh {{kind}} disconnect
138+
./scripts/connect_kind.sh {{kind}} disconnect
139139

140140
ssh-cloudbeat:
141141
CLOUDBEAT_POD=$( kubectl get pods -o=name -n kube-system | grep -m 1 "cloudbeat" ) && \
@@ -155,7 +155,7 @@ generate-mocks:
155155

156156
# run to validate no mocks are missing
157157
validate-mocks:
158-
./.ci/scripts/validate-mocks.sh
158+
./scripts/validate-mocks.sh
159159

160160

161161
#### TESTS ####
File renamed without changes.

‎scripts/make/common.bash

-26
Original file line numberDiff line numberDiff line change
@@ -80,32 +80,6 @@ setup_go_path() {
8080
debug "GOPATH=${GOPATH}"
8181
}
8282

83-
jenkins_setup() {
84-
: "${HOME:?Need to set HOME to a non-empty value.}"
85-
: "${WORKSPACE:?Need to set WORKSPACE to a non-empty value.}"
86-
87-
if [ -z ${GO_VERSION:-} ]; then
88-
get_go_version
89-
fi
90-
91-
# Setup Go.
92-
export GOPATH=${WORKSPACE}
93-
export PATH=${GOPATH}/bin:${PATH}
94-
eval "$(gvm ${GO_VERSION})"
95-
96-
# Workaround for Python virtualenv path being too long.
97-
export TEMP_PYTHON_ENV=$(mktemp -d)
98-
export PYTHON_ENV="${TEMP_PYTHON_ENV}/python-env"
99-
100-
# Write cached magefile binaries to workspace to ensure
101-
# each run starts from a clean slate.
102-
export MAGEFILE_CACHE="${WORKSPACE}/.magefile"
103-
104-
# Enable verbose output for Mage,
105-
# to help diagnose build failures.
106-
export MAGEFILE_VERBOSE=1
107-
}
108-
10983
docker_setup() {
11084
OS="$(uname)"
11185
case $OS in
File renamed without changes.

0 commit comments

Comments
 (0)
Please sign in to comment.