Skip to content

Commit b8c7eba

Browse files
authored
Cherry-pick to 7.9: [CI] MacOS stages for branches/tags and PRs when certain conditions (elastic#20069) (elastic#20333)
* [CI] MacOS stages for branches/tags and PRs when certain conditions (elastic#20069) * [CI] fix null string with contains (elastic#20182)
1 parent d1d81cc commit b8c7eba

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

Jenkinsfile

+20-19
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,15 @@ pipeline {
3737
rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true])
3838
}
3939
triggers {
40-
issueCommentTrigger('(?i).*(?:jenkins\\W+)?run\\W+(?:the\\W+)?tests(?:\\W+please)?.*')
40+
issueCommentTrigger('(?i)(.*(?:jenkins\\W+)?run\\W+(?:the\\W+)?tests(?:\\W+please)?.*|^/test(\\W+macos)?$)')
4141
}
4242
parameters {
4343
booleanParam(name: 'runAllStages', defaultValue: false, description: 'Allow to run all stages.')
4444
booleanParam(name: 'windowsTest', defaultValue: true, description: 'Allow Windows stages.')
45-
booleanParam(name: 'macosTest', defaultValue: true, description: 'Allow macOS stages.')
46-
45+
booleanParam(name: 'macosTest', defaultValue: false, description: 'Allow macOS stages.')
4746
booleanParam(name: 'allCloudTests', defaultValue: false, description: 'Run all cloud integration tests.')
4847
booleanParam(name: 'awsCloudTests', defaultValue: false, description: 'Run AWS cloud integration tests.')
4948
string(name: 'awsRegion', defaultValue: 'eu-central-1', description: 'Default AWS region to use for testing.')
50-
5149
booleanParam(name: 'debug', defaultValue: false, description: 'Allow debug logging for Jenkins steps')
5250
booleanParam(name: 'dry_run', defaultValue: false, description: 'Skip build steps, it is for testing pipeline flow')
5351
}
@@ -100,7 +98,6 @@ pipeline {
10098
mageTarget(context: "Elastic Agent x-pack Linux", directory: "x-pack/elastic-agent", target: "build test")
10199
}
102100
}
103-
104101
stage('Elastic Agent x-pack Windows'){
105102
agent { label 'windows-immutable && windows-2019' }
106103
options { skipDefaultCheckout() }
@@ -114,14 +111,13 @@ pipeline {
114111
mageTargetWin(context: "Elastic Agent x-pack Windows Unit test", directory: "x-pack/elastic-agent", target: "build unitTest")
115112
}
116113
}
117-
118114
stage('Elastic Agent Mac OS X'){
119115
agent { label 'macosx' }
120116
options { skipDefaultCheckout() }
121117
when {
122118
beforeAgent true
123119
expression {
124-
return env.BUILD_ELASTIC_AGENT_XPACK != "false" && params.macosTest
120+
return env.BUILD_ELASTIC_AGENT_XPACK != "false" && env.BUILD_ON_MACOS != 'false'
125121
}
126122
}
127123
steps {
@@ -133,7 +129,6 @@ pipeline {
133129
}
134130
}
135131
}
136-
137132
stage('Filebeat oss'){
138133
agent { label 'ubuntu-18 && immutable' }
139134
options { skipDefaultCheckout() }
@@ -166,7 +161,7 @@ pipeline {
166161
when {
167162
beforeAgent true
168163
expression {
169-
return env.BUILD_FILEBEAT != "false" && params.macosTest
164+
return env.BUILD_FILEBEAT != "false" && env.BUILD_ON_MACOS != 'false'
170165
}
171166
}
172167
steps {
@@ -184,7 +179,7 @@ pipeline {
184179
when {
185180
beforeAgent true
186181
expression {
187-
return env.BUILD_FILEBEAT_XPACK != "false" && params.macosTest
182+
return env.BUILD_FILEBEAT_XPACK != "false" && env.BUILD_ON_MACOS != 'false'
188183
}
189184
}
190185
steps {
@@ -243,7 +238,7 @@ pipeline {
243238
when {
244239
beforeAgent true
245240
expression {
246-
return params.macosTest
241+
return env.BUILD_ON_MACOS != 'false'
247242
}
248243
}
249244
steps {
@@ -302,7 +297,7 @@ pipeline {
302297
when {
303298
beforeAgent true
304299
expression {
305-
return env.BUILD_AUDITBEAT != "false" && params.macosTest
300+
return env.BUILD_AUDITBEAT != "false" && env.BUILD_ON_MACOS != 'false'
306301
}
307302
}
308303
steps {
@@ -346,7 +341,7 @@ pipeline {
346341
when {
347342
beforeAgent true
348343
expression {
349-
return env.BUILD_AUDITBEAT_XPACK != "false" && params.macosTest
344+
return env.BUILD_AUDITBEAT_XPACK != "false" && env.BUILD_ON_MACOS != 'false'
350345
}
351346
}
352347
steps {
@@ -499,7 +494,7 @@ pipeline {
499494
when {
500495
beforeAgent true
501496
expression {
502-
return env.BUILD_METRICBEAT != "false" && params.macosTest
497+
return env.BUILD_METRICBEAT != "false" && env.BUILD_ON_MACOS != 'false'
503498
}
504499
}
505500
steps {
@@ -512,7 +507,7 @@ pipeline {
512507
when {
513508
beforeAgent true
514509
expression {
515-
return env.BUILD_METRICBEAT_XPACK != "false" && params.macosTest
510+
return env.BUILD_METRICBEAT_XPACK != "false" && env.BUILD_ON_MACOS != 'false'
516511
}
517512
}
518513
steps {
@@ -571,7 +566,7 @@ pipeline {
571566
when {
572567
beforeAgent true
573568
expression {
574-
return params.macosTest
569+
return env.BUILD_ON_MACOS != 'false'
575570
}
576571
}
577572
steps {
@@ -682,7 +677,7 @@ pipeline {
682677
when {
683678
beforeAgent true
684679
expression {
685-
return params.macosTest
680+
return env.BUILD_ON_MACOS != 'false'
686681
}
687682
}
688683
steps {
@@ -754,7 +749,7 @@ pipeline {
754749
when {
755750
beforeAgent true
756751
expression {
757-
return params.macosTest
752+
return env.BUILD_ON_MACOS != 'false'
758753
}
759754
}
760755
steps {
@@ -772,7 +767,7 @@ pipeline {
772767
when {
773768
beforeAgent true
774769
expression {
775-
return params.macosTest
770+
return env.BUILD_ON_MACOS != 'false'
776771
}
777772
}
778773
steps {
@@ -1330,6 +1325,12 @@ def loadConfigEnvVars(){
13301325

13311326
// Skip all the stages for changes only related to the documentation
13321327
env.ONLY_DOCS = isDocChangedOnly()
1328+
1329+
// Enable macOS builds when required
1330+
env.BUILD_ON_MACOS = (params.macosTest // UI Input parameter is set to true
1331+
|| !isPR() // For branches and tags
1332+
|| matchesPrLabel(label: 'macOS') // If `macOS` GH label (Case-Sensitive)
1333+
|| (env.GITHUB_COMMENT?.toLowerCase()?.contains('/test macos'))) // If `/test macos` in the GH comment (Case-Insensitive)
13331334
}
13341335

13351336
/**

README.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,19 @@ your dev environment to build Beats from the source.
8484

8585
## Snapshots
8686

87-
For testing purposes, we generate snapshot builds that you can find [here](https://beats-ci.elastic.co/job/elastic+beats+master+multijob-package-linux/lastSuccessfulBuild/gcsObjects/). Please be aware that these are built on top of master and are not meant for production.
87+
For testing purposes, we generate snapshot builds that you can find [here](https://beats-ci.elastic.co/job/Beats/job/packaging/job/master/lastSuccessfulBuild/gcsObjects/). Please be aware that these are built on top of master and are not meant for production.
88+
89+
## CI
90+
91+
It is possible to trigger some jobs by putting a comment on a GitHub PR.
92+
(This service is only available for users affiliated with Elastic and not for open-source contributors.)
93+
94+
* [beats][]
95+
* `jenkins run the tests please` or `jenkins run tests` or `/test` will kick off a default build.
96+
* `/test macos` will kick off a default build with also the `macos` stages.
97+
* [apm-beats-update][]
98+
* `/run apm-beats-update`
99+
100+
101+
[beats]: https://beats-ci.elastic.co/job/Beats/job/beats-beats-mbp/
102+
[apm-beats-update]: https://beats-ci.elastic.co/job/Beats/job/apm-beats-update/

0 commit comments

Comments
 (0)