-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
95 lines (94 loc) · 5.21 KB
/
Copy pathJenkinsfile
File metadata and controls
95 lines (94 loc) · 5.21 KB
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
pipeline {
agent none
// CBL_VERSION, SGW_VERSION, and TS_TEST_FILTER are UI defined params and their default values.
// That's because we want to be able to trigger this job with different versions without having to modify the Jenkinsfile.
// The default values in the UI will be used if no parameters are provided at build time.
// But just for reference, these are the params that are used by the job :
// string(name: 'CBL_VERSION', description: 'Couchbase Lite Version to use, eg : "4" for latest version-build, or "4.1.0-18" for specific version and build')
// string(name: 'SGW_VERSION', description: 'Sync Gateway Version to use, eg : its the same way, check out "resolveProgetVersion" function for more details)')
// string(name: 'TS_TEST_FILTER', description: 'An optional filter for running a subset of tests')
options {
ansiColor('xterm')
timestamps()
}
stages {
stage('Init') {
agent any
steps {
script {
if (params.CBL_VERSION == '') { error "CBL_VERSION is required" }
if (params.SGW_VERSION == '') { error "SGW_VERSION is required" }
def proget = load 'jenkins/pipelines/shared/resolveProgetVersion.groovy'
env.CBL_VERSION = proget.resolveProgetVersion("couchbase-lite-ios", params.CBL_VERSION, 'CBL_VERSION')
env.SGW_VERSION = proget.resolveProgetVersion('sync-gateway', params.SGW_VERSION, 'SGW_VERSION')
env.TS_TEST_FILTER = params.TS_TEST_FILTER ?: ''
currentBuild.displayName = "CBL:${env.CBL_VERSION} SGW:${env.SGW_VERSION} (#${currentBuild.number})"
}
}
}
stage('Prebuild Servers') {
steps {
build job: 'prebuild-test-server',
parameters: [
string(name: 'TS_PLATFORM', value: 'c_macos'),
string(name: 'CBL_VERSION', value: env.CBL_VERSION),
],
wait: true,
propagate: true
}
}
stage('Run Test') {
agent { label 'mac-mini-new' }
environment {
KEYCHAIN_PASSWORD = credentials('mac-mini-new-keychain-password')
PATH = "/opt/homebrew/opt/python@3.10/bin:/opt/homebrew/bin:/usr/local/bin:${env.PATH}"
TS_ARTIFACTS_DIR = 'sgw'
// pytest's graceful stop budget (seconds), applied by the timeout_fixture plugin via
// --session-timeout. Kept comfortably below the stage timeout below so pytest stops itself
// gracefully -- with a runway to finish junit/greenboard/sgcollect -- before Jenkins' hard SIGTERM.
CBL_PYTEST_SESSION_TIMEOUT = '9000'
}
steps {
// Unlock keychain:
sh "security unlock-keychain -p '${KEYCHAIN_PASSWORD}' ~/Library/Keychains/login.keychain-db"
echo "=== Run SGW Tests"
timeout(time: 160, unit: 'MINUTES') {
sh "jenkins/pipelines/QE/sgw/test.sh ${env.CBL_VERSION} ${env.SGW_VERSION} --test-filter '${env.TS_TEST_FILTER}'"
}
echo "=== SGW Tests Complete"
}
post {
always {
// Publish and archive pytest's JUnit XML so
// per-test failures (messages and tracebacks) are
// surfaced in Jenkins even if teardown fails.
script {
try {
junit testResults: '*/junit_result.xml', allowEmptyResults: true
archiveArtifacts artifacts: '*/junit_result.xml', fingerprint: true, allowEmptyArchive: true
} catch (err) {
echo "WARNING: Failed to publish/archive JUnit XML: ${err}"
}
}
echo "=== Teardown SGW Tests"
timeout(time: 5, unit: 'MINUTES') {
sh "jenkins/pipelines/QE/sgw/teardown.sh"
}
// Archived after teardown because teardown's move_artifacts
// is what populates tests/sgw/ (the whole tests/ tree runs
// in one session, so artifacts live at the tests/ root).
archiveArtifacts artifacts: 'tests/sgw/**/*', fingerprint: true, allowEmptyArchive: true
echo "=== SGW Test Teardown Complete"
}
}
}
}
post {
failure {
mail bcc: '', body: "Project: <a href='${env.BUILD_URL}'>${env.JOB_NAME}</a> has failed!", cc: '', charset: 'UTF-8', from: 'jenkins@couchbase.com', mimeType: 'text/html', replyTo: 'no-reply@couchbase.com', subject: "${env.JOB_NAME} failed", to: "vipul.bhardwaj@couchbase.com";
}
fixed {
mail bcc: '', body: "Project: <a href='${env.BUILD_URL}'>${env.JOB_NAME}</a> is back to normal (fixed).", cc: '', charset: 'UTF-8', from: 'jenkins@couchbase.com', mimeType: 'text/html', replyTo: 'no-reply@couchbase.com', subject: "${env.JOB_NAME} fixed", to: "vipul.bhardwaj@couchbase.com";
}
}
}