forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
detectDockerAgent.groovy
28 lines (28 loc) · 1.06 KB
/
detectDockerAgent.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
Map call(Map args = [:]) {
def lib = library(identifier: "jenkins@20211123", retriever: legacySCM(scm))
String manifest = args.manifest ?: "manifests/${INPUT_MANIFEST}"
def inputManifest = lib.jenkins.InputManifest.new(readYaml(file: manifest))
dockerImage = inputManifest.ci?.image?.name ?: 'opensearchstaging/ci-runner:ci-runner-centos7-v1'
dockerArgs = inputManifest.ci?.image?.args
// Using default javaVersion as openjdk-17
String javaVersion = 'openjdk-17'
java.util.regex.Matcher jdkMatch = (dockerArgs =~ /openjdk-\d+/)
if (jdkMatch.find()) {
def jdkMatchLine = jdkMatch[0]
javaVersion = jdkMatchLine
}
echo "Using Docker image ${dockerImage} (${dockerArgs})"
echo "Using java version ${javaVersion}"
return [
image: dockerImage,
args: dockerArgs,
javaVersion: javaVersion
]
}