[es-snapshots] Trigger packer cache job using API instead of pipeline (#133246)

This commit is contained in:
Brian Seeders 2022-05-31 15:20:20 -04:00 committed by GitHub
parent 401ef7c76f
commit 04ed6f8df1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 11 deletions

View file

@ -8,7 +8,7 @@
"name": "kibana-buildkite",
"version": "1.0.0",
"dependencies": {
"kibana-buildkite-library": "git+https://git@github.com/elastic/kibana-buildkite-library#4ecaba35293fb635cf92ca205ee84fca52f19e2e"
"kibana-buildkite-library": "git+https://git@github.com/elastic/kibana-buildkite-library#6a73a417decc52f309ede3644577c9dca7b411a2"
}
},
"node_modules/@nodelib/fs.scandir": {
@ -368,8 +368,8 @@
},
"node_modules/kibana-buildkite-library": {
"version": "1.0.0",
"resolved": "git+https://git@github.com/elastic/kibana-buildkite-library.git#4ecaba35293fb635cf92ca205ee84fca52f19e2e",
"integrity": "sha512-AjX3YyovsyYQ7MBoXQcHdyuFbnYZIChxr+gGApTFVNvJx4z9FeuKxQLKfDuONlZpNliHHgaenmf5APU/ZUqxVA==",
"resolved": "git+https://git@github.com/elastic/kibana-buildkite-library.git#6a73a417decc52f309ede3644577c9dca7b411a2",
"integrity": "sha512-SMW4Eoc/Tkg2lW63iB34obeiqCMhW4a7n3wWa7Ps63eI7+74QlIJha6K5Fa4fO/08ABZ6nEqsWeAOYAFnVLF7g==",
"license": "MIT",
"dependencies": {
"@octokit/rest": "^18.10.0",
@ -839,9 +839,9 @@
}
},
"kibana-buildkite-library": {
"version": "git+https://git@github.com/elastic/kibana-buildkite-library.git#4ecaba35293fb635cf92ca205ee84fca52f19e2e",
"integrity": "sha512-AjX3YyovsyYQ7MBoXQcHdyuFbnYZIChxr+gGApTFVNvJx4z9FeuKxQLKfDuONlZpNliHHgaenmf5APU/ZUqxVA==",
"from": "kibana-buildkite-library@git+https://git@github.com/elastic/kibana-buildkite-library#4ecaba35293fb635cf92ca205ee84fca52f19e2e",
"version": "git+https://git@github.com/elastic/kibana-buildkite-library.git#6a73a417decc52f309ede3644577c9dca7b411a2",
"integrity": "sha512-SMW4Eoc/Tkg2lW63iB34obeiqCMhW4a7n3wWa7Ps63eI7+74QlIJha6K5Fa4fO/08ABZ6nEqsWeAOYAFnVLF7g==",
"from": "kibana-buildkite-library@git+https://git@github.com/elastic/kibana-buildkite-library#6a73a417decc52f309ede3644577c9dca7b411a2",
"requires": {
"@octokit/rest": "^18.10.0",
"axios": "^0.21.4",

View file

@ -3,6 +3,6 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"kibana-buildkite-library": "git+https://git@github.com/elastic/kibana-buildkite-library#4ecaba35293fb635cf92ca205ee84fca52f19e2e"
"kibana-buildkite-library": "git+https://git@github.com/elastic/kibana-buildkite-library#6a73a417decc52f309ede3644577c9dca7b411a2"
}
}

View file

@ -12,7 +12,3 @@ steps:
command: .buildkite/scripts/steps/es_snapshots/promote.sh
agents:
queue: kibana-default
- wait
- trigger: kibana-agent-packer-cache
async: true
branches: main

View file

@ -2,6 +2,7 @@
set -euo pipefail
echo "--- Promote snapshot"
export ES_SNAPSHOT_MANIFEST="${ES_SNAPSHOT_MANIFEST:-"$(buildkite-agent meta-data get ES_SNAPSHOT_MANIFEST)"}"
cat << EOF | buildkite-agent annotate --style "info"
@ -11,3 +12,8 @@ cat << EOF | buildkite-agent annotate --style "info"
EOF
node "$(dirname "${0}")/promote_manifest.js" "$ES_SNAPSHOT_MANIFEST"
if [[ "$BUILDKITE_BRANCH" == "main" ]]; then
echo "--- Trigger agent packer cache pipeline"
node .buildkite/scripts/steps/trigger_packer_cache.js
fi

View file

@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
const { BuildkiteClient } = require('kibana-buildkite-library');
(async () => {
try {
const client = new BuildkiteClient();
const build = await client.triggerBuild('kibana-agent-packer-cache', {
commit: 'HEAD',
branch: 'main',
ignore_pipeline_branch_filters: true, // Required because of a Buildkite bug
});
console.log(`Triggered build: ${build.web_url}`);
process.exit(0);
} catch (ex) {
console.error('Buildkite API Error', ex.toString());
if (ex.response) {
console.error('HTTP Error Response Status', ex.response.status);
console.error('HTTP Error Response Body', ex.response.data);
}
process.exit(1);
}
})();