forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunIntegTestScript.groovy
57 lines (49 loc) · 2.09 KB
/
runIntegTestScript.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* 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.
*/
void call(Map args = [:]) {
lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm))
String jobName = args.jobName ?: 'distribution-build-opensearch'
def buildManifest = lib.jenkins.BuildManifest.new(readYaml(file: args.buildManifest))
String buildId = buildManifest.build.id
echo "Build Id: ${buildId}"
String artifactRootUrl = buildManifest.getArtifactRootUrl(jobName, buildId)
echo "Artifact root URL: ${artifactRootUrl}"
String localPath = args.localPath ?: 'None'
String paths = generatePaths(buildManifest, artifactRootUrl, localPath)
echo "Paths: ${paths}"
String component = args.componentName
echo "Component: ${component}"
sh([
'./test.sh',
'integ-test',
"${args.testManifest}",
"--component ${component}",
"--test-run-id ${env.BUILD_NUMBER}",
"--paths ${paths}",
].join(' '))
}
String generatePaths(buildManifest, artifactRootUrl, localPath) {
String name = buildManifest.build.name
String version = buildManifest.build.version
String platform = buildManifest.build.platform
String architecture = buildManifest.build.architecture
String distribution = buildManifest.build.distribution
String latestOpenSearchArtifactRootUrl = "https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${version}/latest/${platform}/${architecture}/${distribution}"
if (localPath.equals('None')) {
echo "No localPath found, download from url"
return name == 'OpenSearch' ?
"opensearch=${artifactRootUrl}" :
"opensearch=${latestOpenSearchArtifactRootUrl} opensearch-dashboards=${artifactRootUrl}"
}
else {
echo "User provides localPath, use local artifacts: ${localPath}"
return name == 'OpenSearch' ?
"opensearch=${localPath}" :
"opensearch=${localPath} opensearch-dashboards=${localPath}"
}
}