forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
120 lines (118 loc) · 3.34 KB
/
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
#!/usr/bin/env groovy
library identifier: 'apm@v1.0.2',
retriever: modernSCM(
[$class: 'GitSCMSource',
credentialsId: 'f94e9298-83ae-417e-ba91-85c279771570',
id: '37cf2c00-2cc7-482e-8c62-7bbffef475e2',
remote: 'git@github.com:elastic/apm-pipeline-library.git'])
pipeline {
agent none
environment {
BASE_DIR="src/github.com/elastic/beats"
}
options {
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30'))
timestamps()
ansiColor('xterm')
disableResume()
durabilityHint('PERFORMANCE_OPTIMIZED')
}
parameters {
booleanParam(name: 'Run_As_Master_Branch', defaultValue: false, description: 'Allow to run any steps on a PR, some steps normally only run on master branch.')
}
stages {
/**
Checkout the code and stash it, to use it on other stages.
*/
stage('Checkout') {
agent { label 'linux && immutable' }
environment {
PATH = "${env.PATH}:${env.WORKSPACE}/bin"
HOME = "${env.WORKSPACE}"
GOPATH = "${env.WORKSPACE}"
}
options { skipDefaultCheckout() }
steps {
dir("${BASE_DIR}"){
checkout scm
}
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
script {
env.GO_VERSION = readFile("${BASE_DIR}/.go-version")
}
}
}
/**
Updating generated files for Beat.
Checks the GO environment.
Checks the Python environment.
Checks YAML files are generated.
Validate that all updates were committed.
*/
stage('Intake') {
agent { label 'linux && immutable' }
options { skipDefaultCheckout() }
environment {
PATH = "${env.PATH}:${env.WORKSPACE}/bin"
HOME = "${env.WORKSPACE}"
GOPATH = "${env.WORKSPACE}"
}
steps {
withEnvWrapper() {
unstash 'source'
dir("${BASE_DIR}"){
sh './dev-tools/jenkins_intake.sh'
}
}
}
}
stage('Test') {
failFast true
parallel {
/**
Run unit tests and report junit results.
*/
stage('Filebeat') {
agent { label 'linux && immutable' }
options { skipDefaultCheckout() }
environment {
PATH = "${env.PATH}:${env.WORKSPACE}/bin"
HOME = "${env.WORKSPACE}"
GOPATH = "${env.WORKSPACE}"
}
steps {
withEnvWrapper() {
unstash 'source'
dir("${BASE_DIR}"){
sh './filebeat/scripts/jenkins/unit-test.sh'
}
}
}
post {
always {
junit(allowEmptyResults: true,
keepLongStdio: true,
testResults: "${BASE_DIR}/build/junit-*.xml")
}
}
}
}
}
}
post {
success {
echoColor(text: '[SUCCESS]', colorfg: 'green', colorbg: 'default')
}
aborted {
echoColor(text: '[ABORTED]', colorfg: 'magenta', colorbg: 'default')
}
failure {
echoColor(text: '[FAILURE]', colorfg: 'red', colorbg: 'default')
//step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${NOTIFY_TO}", sendToIndividuals: false])
}
unstable {
echoColor(text: '[UNSTABLE]', colorfg: 'yellow', colorbg: 'default')
}
}
}