Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ spec:
allow_rebuilds: true
cancel_intermediate_builds: false
branch_configuration: main
pipeline_file: .buildkite/version_bump.yml
pipeline_file: .buildkite/pipelines/version_bump.yml
initial_step_plugins:
- sparse-checkout#v1.6.0:
paths:
- .buildkite
cleanup_sparse_state: true
provider_settings:
trigger_mode: none
repository: elastic/kibana
Expand Down
7 changes: 6 additions & 1 deletion .buildkite/pipeline-utils/buildkite/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import { execFileSync } from 'child_process';
import fs from 'fs';
import { load as loadYaml } from 'js-yaml';

export function emitPipeline(pipelineSteps: string[]) {
export function emitPipeline(pipelineSteps: string[], debug = false) {
const pipelineStr = [...new Set(pipelineSteps)].join('\n');

if (debug) {
console.warn('Emitting pipeline:\n', pipelineStr);
}

console.log(pipelineStr);
}

Expand Down
37 changes: 16 additions & 21 deletions .buildkite/pipelines/version_bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,29 @@ notify:
if: (build.branch == 'main' || build.branch =~ /^[0-9]+\.[0-9x]+\$/) && (build.state == 'passed' || build.state == 'failed')
- slack:
channels:
- '#kibana-operations'
- '#mission-control'
message: |
🚦 Pipeline waiting for approval 🚦
Repo: `${REPO}`

Ready to fetch DRA artifacts - please unblock when ready.
New version: `${NEW_VERSION}`
Branch: `${BRANCH}`
Workflow: `${WORKFLOW}`
${BUILDKITE_BUILD_URL}
if: build.state == "blocked"
Kibana has been bumped to `${NEW_VERSION}` on branch `${BRANCH}` and a DRA build has begun.
Build: ${BUILDKITE_BUILD_URL}
if: build.state == "passed"

steps:
# TODO: replace this block step by real version bump logic
- block: 'Ready to fetch for DRA artifacts?'
prompt: |
Unblock when your team is ready to proceed.
- command: .buildkite/scripts/steps/version_bump/bump.sh
key: bump-version
label: Bump version
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
machineType: n2-standard-4
env:
DRY_RUN: 'true'

Trigger parameters:
- NEW_VERSION: ${NEW_VERSION}
- BRANCH: ${BRANCH}
- WORKFLOW: ${WORKFLOW}
key: block-get-dra-artifacts
blocked_state: running
- wait

- label: 'Fetch DRA Artifacts'
key: fetch-dra-artifacts
depends_on: block-get-dra-artifacts
depends_on: bump-version
agents:
image: docker.elastic.co/release-eng/wolfi-build-essential-release-eng:latest
cpu: 250m
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
steps:
- name: 'Bump package.json versions'
key: bump-package-json-versions
command: .buildkite/scripts/steps/version_bump/bump_package_json_versions.sh
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
machineType: n2-standard-4
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- name: 'Bump package.json versions (to main)'
key: bump-package-json-versions-to-main
command: .buildkite/scripts/steps/version_bump/bump_package_json_versions.sh
env:
OVERRIDE_BRANCH: main
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
machineType: n2-standard-4
9 changes: 9 additions & 0 deletions .buildkite/pipelines/version_bump/bump_versions_json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
steps:
- name: 'Bump versions.json'
key: bump-versions-json
command: .buildkite/scripts/steps/version_bump/bump_versions_json.sh
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
machineType: n2-standard-4
4 changes: 4 additions & 0 deletions .buildkite/pipelines/version_bump/create_new_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- name: 'Create new release branch'
key: create-new-branch
command: .buildkite/scripts/steps/version_bump/create_new_branch_of_main.sh
4 changes: 4 additions & 0 deletions .buildkite/pipelines/version_bump/ensure_version_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- name: 'Ensure version label exists'
key: ensure-version-label
command: .buildkite/scripts/steps/version_bump/ensure_version_label.sh
4 changes: 4 additions & 0 deletions .buildkite/pipelines/version_bump/notify_branch_created.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- name: 'Notify Slack: branch created'
key: notify-branch-created
command: .buildkite/scripts/steps/version_bump/notify_branch_created.sh
8 changes: 8 additions & 0 deletions .buildkite/pipelines/version_bump/reconcile_pr_labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
steps:
- name: 'Reconcile PR Labels'
key: reconcile-pr-labels
depends_on:
- update-label-color
command: .buildkite/scripts/steps/version_bump/reconcile_pr_labels.sh
env:
DRY_RUN: 'true'
12 changes: 12 additions & 0 deletions .buildkite/pipelines/version_bump/trigger_dra_snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
steps:
- name: mock kibana snapshot build
if: build.env("DRY_RUN") == "true"
command: sleep 10

- name: Trigger DRA Snapshot Build
key: trigger-dra-snapshot
if: build.env("DRY_RUN") == "false"
trigger: kibana-artifacts-snapshot
async: false
build:
branch: '${BRANCH}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
steps:
- name: Trigger DRA Snapshot Build
key: trigger-dra-snapshot-on-main
trigger: kibana-artifacts-snapshot
if: build.env("DRY_RUN") != "true"
async: false
build:
branch: 'main'
8 changes: 8 additions & 0 deletions .buildkite/pipelines/version_bump/trigger_dra_staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
steps:
- name: Trigger DRA Staging Build
key: trigger-dra-staging
trigger: kibana-artifacts-staging
if: build.env("DRY_RUN") != "true"
async: false
build:
branch: '${BRANCH}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
steps:
- name: mock build es snapshot
key: mock-build-es-snapshot
if: build.env("DRY_RUN") == "true"
command: sleep 10

- name: mock promote es snapshot
if: build.env("DRY_RUN") == "true"
depends_on: mock-build-es-snapshot
command: |

buildkite-agent pipeline upload << PIPELINE
steps:
- name: 'Mock Promote ES Snapshot trigger'
command: sleep 10

PIPELINE

- key: build-es-snapshot
label: Build ES Snapshot
trigger: kibana-elasticsearch-snapshot-build
async: false
if: build.env("DRY_RUN") == "false"
build:
branch: $BRANCH
env:
PARENT_TRIGGER_JOB_ID: '${BUILDKITE_JOB_ID}'

- key: promote-es-snapshot
label: 'Upload promote step'
if: build.env("DRY_RUN") == "false"
depends_on: build-es-snapshot
command: |
ES_SNAPSHOT_MANIFEST="$(buildkite-agent meta-data get es_snapshot_manifest)"

buildkite-agent pipeline upload << PIPELINE
steps:
- label: 'Promote ES Snapshot'
trigger: kibana-elasticsearch-snapshot-promote
async: false
build:
branch: '$${BRANCH}'
env:
ES_SNAPSHOT_MANIFEST: '$${ES_SNAPSHOT_MANIFEST}'
PIPELINE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
steps:
- key: build-es-snapshot
label: Build ES Snapshot
trigger: kibana-elasticsearch-snapshot-build
async: false
if: build.env("DRY_RUN") != "true"
build:
branch: main
env:
PARENT_TRIGGER_JOB_ID: '${BUILDKITE_JOB_ID}'

- key: promote-es-snapshot
label: 'Upload promote step'
depends_on: build-es-snapshot
if: build.env("DRY_RUN") != "true"
command: |
ES_SNAPSHOT_MANIFEST="$(buildkite-agent meta-data get es_snapshot_manifest)"

buildkite-agent pipeline upload << PIPELINE
steps:
- label: 'Promote ES Snapshot'
trigger: kibana-elasticsearch-snapshot-promote
async: false
build:
branch: 'main'
env:
ES_SNAPSHOT_MANIFEST: '$${ES_SNAPSHOT_MANIFEST}'
PIPELINE
9 changes: 9 additions & 0 deletions .buildkite/pipelines/version_bump/update_label_color.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
steps:
- name: 'Update Label Color'
key: update-label-color
command: .buildkite/scripts/steps/version_bump/update_label_color.sh
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
machineType: n2-standard-4
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
steps:
- name: 'Update pipeline resource definitions'
key: update-pipeline-resource-definitions
command: .buildkite/scripts/steps/version_bump/update_pipeline_resource_definitions.sh
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
machineType: n4-standard-4
4 changes: 4 additions & 0 deletions .buildkite/pipelines/version_bump/update_release_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- name: 'Update release branch config'
key: update-release-branch
command: .buildkite/scripts/steps/version_bump/update_release_branch.sh
4 changes: 4 additions & 0 deletions .buildkite/scripts/steps/es_snapshots/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ cat << EOF | buildkite-agent annotate --style "info"
- \`ES_SNAPSHOT_ID\` - \`$(buildkite-agent meta-data get ES_SNAPSHOT_ID)\`
EOF

if [ "$BUILDKITE_TRIGGERED_FROM_BUILD_PIPELINE_SLUG" = "kibana-version-bump" ]; then
buildkite-agent meta-data set es_snapshot_manifest "$ES_SNAPSHOT_MANIFEST" --job "$PARENT_TRIGGER_JOB_ID"
fi

cat << EOF | buildkite-agent pipeline upload
steps:
- trigger: 'kibana-elasticsearch-snapshot-verify'
Expand Down
6 changes: 6 additions & 0 deletions .buildkite/scripts/steps/version_bump/bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -euo pipefail

ts-node .buildkite/scripts/steps/version_bump/pipeline.ts | buildkite-agent pipeline upload

103 changes: 103 additions & 0 deletions .buildkite/scripts/steps/version_bump/bump_package_json_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/env bash

set -euo pipefail

.buildkite/scripts/bootstrap.sh

source "$(dirname "$0")/wait_for_pr_merge.sh"

branch_to_merge_into="${OVERRIDE_BRANCH:-$BRANCH}"

git fetch origin $branch_to_merge_into
git checkout -B "$branch_to_merge_into" "origin/$branch_to_merge_into"

old_version=""
store_old_version() {
old_version=$(jq -r '.version' package.json)
echo "Current version: $old_version"
echo "New version: $NEW_VERSION"

buildkite-agent meta-data set "OLD_VERSION" "$old_version"
}

update_package_json_version() {
echo --- Bump package.json versions
sed -i "s/\"version\": \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\": \"${NEW_VERSION}\"/g" package.json
sed -i "s/\"version\": \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\": \"${NEW_VERSION}\"/g" x-pack/package.json
}

update_initial_app_data() {
echo --- Bump initial_app_data kibanaVersion
local target="x-pack/solutions/search/plugins/enterprise_search/common/__mocks__/initial_app_data.ts"
if [[ -f "$target" ]]; then
sed -i "s/kibanaVersion: '[0-9]\+\.[0-9]\+\.[0-9]\+'/kibanaVersion: '${NEW_VERSION}'/" "$target"
else
echo "File not found, skipping: $target"
fi
}

update_kibana_migrator_utils() {
echo --- Bump BASELINE_ELASTICSEARCH_VERSION
local target="src/core/server/integration_tests/saved_objects/migrations/kibana_migrator_archive_utils.ts"
sed -i "s/BASELINE_ELASTICSEARCH_VERSION = '[0-9]\+\.[0-9]\+\.[0-9]\+'/BASELINE_ELASTICSEARCH_VERSION = '${NEW_VERSION}'/" "$target"
}

delete_baseline_archives() {
echo --- Deleting baseline archives
local archive_dir="src/core/server/integration_tests/saved_objects/migrations/archives"
find "$archive_dir" -type f -name "${old_version}_baseline_*.zip" -delete
}

run_tests() {
local test_file="src/core/server/integration_tests/saved_objects/migrations/group1/create_test_archives.test.ts"
echo --- Temporarily unskipping and running "$test_file"
sed -i "s/describe\.skip(/describe(/" "$test_file"
local exit_code=0

node scripts/jest_integration.js -u "$test_file" || exit_code=$?

sed -i "s/describe(/describe.skip(/" "$test_file"


# This test MUST run after the create_test_archives.test.ts test, as it relies on the snapshots created by that test to update the snapshots for the v2 migration tests
echo --- Running integration tests to update snapshots
node scripts/jest_integration.js -u src/core/server/integration_tests/saved_objects/migrations/group1/v2_migration.test.ts

return "$exit_code"
}

store_old_version

update_package_json_version

update_initial_app_data

update_kibana_migrator_utils

delete_baseline_archives

# Run integration tests to update snapshots
run_tests

echo --- Committing version bump changes
git config --global user.name kibanamachine
git config --global user.email '42973632+kibanamachine@users.noreply.github.com'

head_branch="bump-versions-$(date +%F_%H-%M-%S)"
git checkout -b "$head_branch"
git add package.json x-pack/package.json x-pack/solutions/search/plugins/enterprise_search/common/__mocks__/initial_app_data.ts src/core/server/integration_tests/saved_objects/migrations/kibana_migrator_archive_utils.ts src/core/server/integration_tests/saved_objects/migrations/archives src/core/server/integration_tests/saved_objects/migrations/group1/__snapshots__/v2_migration.test.ts.snap
git commit -m "[version bump] Bump version to ${NEW_VERSION}"
git push origin "$head_branch"

prUrl=$(gh pr create --repo elastic/kibana --base "$branch_to_merge_into" --head "$head_branch" --title "[bump version] $(date +%F) Bump package.json versions to ${NEW_VERSION}" --body "Generated by ${BUILDKITE_BUILD_URL}" --label "release_note:skip" --label "backport:skip")
echo "Opened PR: $prUrl"

if [ "${DRY_RUN:-}" = "true" ]; then
echo "DRY_RUN is enabled — skipping auto-merge and merge wait"
else
gh pr merge --repo elastic/kibana --auto --squash --delete-branch "$prUrl"

wait_for_pr_merge "$prUrl"
fi


Loading
Loading