Skip to content

Commit

Permalink
Cherry-pick to 7.9: [CI] MacOS stages for branches/tags and PRs when …
Browse files Browse the repository at this point in the history
…certain conditions (#20069) (#20333)

* [CI] MacOS stages for branches/tags and PRs when certain conditions (#20069)
* [CI] fix null string with contains (#20182)
  • Loading branch information
v1v authored Jul 31, 2020
1 parent 0d6d5d5 commit 3152e56
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
39 changes: 20 additions & 19 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ pipeline {
rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true])
}
triggers {
issueCommentTrigger('(?i).*(?:jenkins\\W+)?run\\W+(?:the\\W+)?tests(?:\\W+please)?.*')
issueCommentTrigger('(?i)(.*(?:jenkins\\W+)?run\\W+(?:the\\W+)?tests(?:\\W+please)?.*|^/test(\\W+macos)?$)')
}
parameters {
booleanParam(name: 'runAllStages', defaultValue: false, description: 'Allow to run all stages.')
booleanParam(name: 'windowsTest', defaultValue: true, description: 'Allow Windows stages.')
booleanParam(name: 'macosTest', defaultValue: true, description: 'Allow macOS stages.')

booleanParam(name: 'macosTest', defaultValue: false, description: 'Allow macOS stages.')
booleanParam(name: 'allCloudTests', defaultValue: false, description: 'Run all cloud integration tests.')
booleanParam(name: 'awsCloudTests', defaultValue: false, description: 'Run AWS cloud integration tests.')
string(name: 'awsRegion', defaultValue: 'eu-central-1', description: 'Default AWS region to use for testing.')

booleanParam(name: 'debug', defaultValue: false, description: 'Allow debug logging for Jenkins steps')
booleanParam(name: 'dry_run', defaultValue: false, description: 'Skip build steps, it is for testing pipeline flow')
}
Expand Down Expand Up @@ -100,7 +98,6 @@ pipeline {
mageTarget(context: "Elastic Agent x-pack Linux", directory: "x-pack/elastic-agent", target: "build test")
}
}

stage('Elastic Agent x-pack Windows'){
agent { label 'windows-immutable && windows-2019' }
options { skipDefaultCheckout() }
Expand All @@ -114,14 +111,13 @@ pipeline {
mageTargetWin(context: "Elastic Agent x-pack Windows Unit test", directory: "x-pack/elastic-agent", target: "build unitTest")
}
}

stage('Elastic Agent Mac OS X'){
agent { label 'macosx' }
options { skipDefaultCheckout() }
when {
beforeAgent true
expression {
return env.BUILD_ELASTIC_AGENT_XPACK != "false" && params.macosTest
return env.BUILD_ELASTIC_AGENT_XPACK != "false" && env.BUILD_ON_MACOS != 'false'
}
}
steps {
Expand All @@ -133,7 +129,6 @@ pipeline {
}
}
}

stage('Filebeat oss'){
agent { label 'ubuntu-18 && immutable' }
options { skipDefaultCheckout() }
Expand Down Expand Up @@ -166,7 +161,7 @@ pipeline {
when {
beforeAgent true
expression {
return env.BUILD_FILEBEAT != "false" && params.macosTest
return env.BUILD_FILEBEAT != "false" && env.BUILD_ON_MACOS != 'false'
}
}
steps {
Expand All @@ -184,7 +179,7 @@ pipeline {
when {
beforeAgent true
expression {
return env.BUILD_FILEBEAT_XPACK != "false" && params.macosTest
return env.BUILD_FILEBEAT_XPACK != "false" && env.BUILD_ON_MACOS != 'false'
}
}
steps {
Expand Down Expand Up @@ -243,7 +238,7 @@ pipeline {
when {
beforeAgent true
expression {
return params.macosTest
return env.BUILD_ON_MACOS != 'false'
}
}
steps {
Expand Down Expand Up @@ -302,7 +297,7 @@ pipeline {
when {
beforeAgent true
expression {
return env.BUILD_AUDITBEAT != "false" && params.macosTest
return env.BUILD_AUDITBEAT != "false" && env.BUILD_ON_MACOS != 'false'
}
}
steps {
Expand Down Expand Up @@ -346,7 +341,7 @@ pipeline {
when {
beforeAgent true
expression {
return env.BUILD_AUDITBEAT_XPACK != "false" && params.macosTest
return env.BUILD_AUDITBEAT_XPACK != "false" && env.BUILD_ON_MACOS != 'false'
}
}
steps {
Expand Down Expand Up @@ -499,7 +494,7 @@ pipeline {
when {
beforeAgent true
expression {
return env.BUILD_METRICBEAT != "false" && params.macosTest
return env.BUILD_METRICBEAT != "false" && env.BUILD_ON_MACOS != 'false'
}
}
steps {
Expand All @@ -512,7 +507,7 @@ pipeline {
when {
beforeAgent true
expression {
return env.BUILD_METRICBEAT_XPACK != "false" && params.macosTest
return env.BUILD_METRICBEAT_XPACK != "false" && env.BUILD_ON_MACOS != 'false'
}
}
steps {
Expand Down Expand Up @@ -571,7 +566,7 @@ pipeline {
when {
beforeAgent true
expression {
return params.macosTest
return env.BUILD_ON_MACOS != 'false'
}
}
steps {
Expand Down Expand Up @@ -682,7 +677,7 @@ pipeline {
when {
beforeAgent true
expression {
return params.macosTest
return env.BUILD_ON_MACOS != 'false'
}
}
steps {
Expand Down Expand Up @@ -754,7 +749,7 @@ pipeline {
when {
beforeAgent true
expression {
return params.macosTest
return env.BUILD_ON_MACOS != 'false'
}
}
steps {
Expand All @@ -772,7 +767,7 @@ pipeline {
when {
beforeAgent true
expression {
return params.macosTest
return env.BUILD_ON_MACOS != 'false'
}
}
steps {
Expand Down Expand Up @@ -1330,6 +1325,12 @@ def loadConfigEnvVars(){

// Skip all the stages for changes only related to the documentation
env.ONLY_DOCS = isDocChangedOnly()

// Enable macOS builds when required
env.BUILD_ON_MACOS = (params.macosTest // UI Input parameter is set to true
|| !isPR() // For branches and tags
|| matchesPrLabel(label: 'macOS') // If `macOS` GH label (Case-Sensitive)
|| (env.GITHUB_COMMENT?.toLowerCase()?.contains('/test macos'))) // If `/test macos` in the GH comment (Case-Insensitive)
}

/**
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,19 @@ your dev environment to build Beats from the source.

## Snapshots

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.
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.

## CI

It is possible to trigger some jobs by putting a comment on a GitHub PR.
(This service is only available for users affiliated with Elastic and not for open-source contributors.)

* [beats][]
* `jenkins run the tests please` or `jenkins run tests` or `/test` will kick off a default build.
* `/test macos` will kick off a default build with also the `macos` stages.
* [apm-beats-update][]
* `/run apm-beats-update`


[beats]: https://beats-ci.elastic.co/job/Beats/job/beats-beats-mbp/
[apm-beats-update]: https://beats-ci.elastic.co/job/Beats/job/apm-beats-update/

0 comments on commit 3152e56

Please sign in to comment.