From 2cac3b285630e52db2769144e0b8ca53441b9c54 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Mon, 10 Apr 2023 08:11:57 -0500 Subject: [PATCH] Revert "[Fleet] Fail build on unable to retrieve agent versions list (#154110)" This reverts commit 99f366a595a9fc398db8d8e8c0498111b4d07557. --- .../build/tasks/fetch_agent_versions_list.ts | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/dev/build/tasks/fetch_agent_versions_list.ts b/src/dev/build/tasks/fetch_agent_versions_list.ts index bc4143f5000da..560c52fad07ba 100644 --- a/src/dev/build/tasks/fetch_agent_versions_list.ts +++ b/src/dev/build/tasks/fetch_agent_versions_list.ts @@ -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 []; }; @@ -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, ' ')