[8.15] [Fleet] Always use a SNAPSHOT version when running elastic-agent docker image (#187777) (#187852)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Fleet] Always use a SNAPSHOT version when running elastic-agent
docker image (#187777)](https://github.com/elastic/kibana/pull/187777)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nicolas
Chaulet","email":"nicolas.chaulet@elastic.co"},"sourceCommit":{"committedDate":"2024-07-09T11:27:20Z","message":"[Fleet]
Always use a SNAPSHOT version when running elastic-agent docker image
(#187777)","sha":"834f8fdb375d0c7eef0de974ae5c0f0c0f19b60a","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","Team:Elastic-Agent-Control-Plane","backport:prev-minor","v8.16.0"],"title":"[Fleet]
Always use a SNAPSHOT version when running elastic-agent docker
image","number":187777,"url":"https://github.com/elastic/kibana/pull/187777","mergeCommit":{"message":"[Fleet]
Always use a SNAPSHOT version when running elastic-agent docker image
(#187777)","sha":"834f8fdb375d0c7eef0de974ae5c0f0c0f19b60a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/187777","number":187777,"mergeCommit":{"message":"[Fleet]
Always use a SNAPSHOT version when running elastic-agent docker image
(#187777)","sha":"834f8fdb375d0c7eef0de974ae5c0f0c0f19b60a"}}]}]
BACKPORT-->

Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
This commit is contained in:
Kibana Machine 2024-07-09 16:25:38 +02:00 committed by GitHub
parent a269eb2783
commit f6c1ad83b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,6 +15,10 @@ export async function getLatestVersion(): Promise<string> {
return pRetry(() => axios('https://artifacts-api.elastic.co/v1/versions'), {
maxRetryTime: 60 * 1000, // 1 minute
})
.then((response) => last(response.data.versions as string[]) || DEFAULT_VERSION)
.then(
(response) =>
last((response.data.versions as string[]).filter((v) => v.includes('-SNAPSHOT'))) ||
DEFAULT_VERSION
)
.catch(() => DEFAULT_VERSION);
}