forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bwc-test.jenkinsfile
162 lines (156 loc) · 5.78 KB
/
bwc-test.jenkinsfile
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
* Copyright OpenSearch Contributors
* 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.
*/
lib = library(identifier: '[email protected]', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
pipeline {
options {
timeout(time: 4, unit: 'HOURS')
buildDiscarder(logRotator(daysToKeepStr: '30'))
}
agent none
environment {
BUILD_MANIFEST = "build-manifest.yml"
DEFAULT_BUILD_JOB_NAME = "distribution-build-opensearch-dashboards"
}
parameters {
string(
name: 'TEST_MANIFEST',
description: 'Test manifest under the manifests folder, e.g. 2.0.0/opensearch-dashboards-2.0.0-test.yml.',
trim: true
)
string(
name: 'BUILD_MANIFEST_URL',
description: 'The build manifest URL, e.g. https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.0.0/98/linux/x64/builds/opensearch-dashboards/manifest.yml.',
trim: true
)
string(
name: 'AGENT_LABEL',
description: 'The agent label where the tests should be executed, e.g. Jenkins-Agent-AL2023-X64-C54xlarge-Docker-Host.',
trim: true
)
}
stages {
stage('verify-parameters') {
agent {
node {
label AGENT_LABEL
}
}
steps {
script {
currentBuild.description = TEST_MANIFEST
if (AGENT_LABEL == '') {
currentBuild.result = 'ABORTED'
error("BWC Tests failed to start. Missing parameter: AGENT_LABEL.")
}
if (TEST_MANIFEST == '' || !fileExists("manifests/${TEST_MANIFEST}")) {
currentBuild.result = 'ABORTED'
error("BWC Tests failed to start. Test manifest was not provided or not found in manifests/${TEST_MANIFEST}.")
}
/*
Rebuilding of this job will result in considering the upstream build as self($JOB_NAME) See https://issues.jenkins.io/browse/JENKINS-61590 for bug
Either trigger from expected upstream job or run a new build
*/
env.BUILD_JOB_NAME = currentBuild.upstreamBuilds ?
currentBuild.upstreamBuilds[0].fullProjectName :
env.DEFAULT_BUILD_JOB_NAME
}
}
}
stage('detect docker image + args') {
agent {
docker {
label 'Jenkins-Agent-AL2023-X64-C54xlarge-Docker-Host'
image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028'
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
steps {
script {
DOCKER_AGENT = detectTestDockerAgent()
}
}
}
stage('bwc-test') {
agent {
docker {
label AGENT_LABEL
image DOCKER_AGENT.image
args DOCKER_AGENT.args
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
steps {
script {
def buildManifestObj = downloadBuildManifest(
url: BUILD_MANIFEST_URL,
path: BUILD_MANIFEST
)
String buildId = buildManifestObj.getArtifactBuildId()
env.BUILD_ID = buildId
echo "BUILD_MANIFEST: ${BUILD_MANIFEST}"
echo "BUILD_ID: ${BUILD_ID}"
runBwcTestScript(
jobName: BUILD_JOB_NAME,
buildManifest: BUILD_MANIFEST,
testManifest: "manifests/${TEST_MANIFEST}",
buildId: BUILD_ID
)
}
}
post {
always {
script {
uploadTestResults(
buildManifestFileName: BUILD_MANIFEST,
jobName: JOB_NAME
)
}
postCleanup()
}
}
}
}
post {
success {
node(AGENT_LABEL) {
script {
def stashed = lib.jenkins.Messages.new(this).get(['bwc-test'])
publishNotification(
icon: ':white_check_mark:',
message: 'BWC Tests Successful',
extra: stashed,
credentialsId: 'jenkins-integ-test-webhook',
manifest: TEST_MANIFEST,
)
postCleanup()
}
}
}
failure {
node(AGENT_LABEL) {
script {
def stashed = lib.jenkins.Messages.new(this).get(['bwc-test'])
publishNotification(
icon: ':warning:',
message: 'Failed BWC Tests',
extra: stashed,
credentialsId: 'jenkins-integ-test-webhook',
manifest: TEST_MANIFEST,
)
postCleanup()
}
}
}
}
}