Skip to content

Commit

Permalink
Revert "[Fleet] Fail build on unable to retrieve agent versions list (#…
Browse files Browse the repository at this point in the history
…154110)"

This reverts commit 99f366a.
  • Loading branch information
jbudz committed Apr 10, 2023
1 parent f6a7b6c commit 2cac3b2
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/dev/build/tasks/fetch_agent_versions_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,22 @@ const getAvailableVersions = async (log: ToolingLog) => {
};
// Endpoint maintained by the web-team and hosted on the elastic website
// See https://github.com/elastic/website-development/issues/9331
const url = 'https://www.elastic.co/content/product_versions';
log.info('Fetching Elastic Agent versions list');
const results = await fetch(url, options);
const rawBody = await results.text();

const url = 'https://www.elastic.co/api/product_versions';
try {
const jsonBody = JSON.parse(rawBody);
log.info('Fetching Elastic Agent versions list');
const results = await fetch(url, options);

const jsonBody = await results.json();

const versions: string[] = (jsonBody.length ? jsonBody[0] : [])
.filter((item: any) => item?.title?.includes('Elastic Agent'))
.map((item: any) => item?.version_number);

log.info(`Retrieved available Elastic Agent versions`);
log.info(`Retrieved available versions`);
return versions;
} catch (error) {
log.warning(`Failed to fetch Elastic Agent versions list`);
log.info(`Status: ${results.status}`);
log.info(rawBody);
if (process.env.BUILDKITE_PULL_REQUEST === 'true') {
log.warning(error);
} else {
throw new Error(error);
}
log.warning(`Failed to fetch versions list`);
log.warning(error);
}
return [];
};
Expand All @@ -54,8 +47,8 @@ export const FetchAgentVersionsList: Task = {
const versionsList = await getAvailableVersions(log);
const AGENT_VERSION_BUILD_FILE = 'x-pack/plugins/fleet/target/agent_versions_list.json';

if (versionsList.length !== 0) {
log.info(`Writing Elastic Agent versions list to ${AGENT_VERSION_BUILD_FILE}`);
if (versionsList !== []) {
log.info(`Writing versions list to ${AGENT_VERSION_BUILD_FILE}`);
await write(
build.resolvePath(AGENT_VERSION_BUILD_FILE),
JSON.stringify(versionsList, null, ' ')
Expand Down

0 comments on commit 2cac3b2

Please sign in to comment.