From e9c1b79b1ec07e6168f401d0c6c43b01cb5d2351 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 22 Jul 2020 10:26:02 +0100 Subject: [PATCH] [CI] MacOS stages for branches/tags and PRs when certain conditions (#20069) --- Jenkinsfile | 39 ++++++++++++++++++++------------------- README.md | 17 ++++++++++++++++- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9d5ddd347454..65704e987014 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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') } @@ -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() } @@ -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 { @@ -133,7 +129,6 @@ pipeline { } } } - stage('Filebeat oss'){ agent { label 'ubuntu-18 && immutable' } options { skipDefaultCheckout() } @@ -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 { @@ -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 { @@ -243,7 +238,7 @@ pipeline { when { beforeAgent true expression { - return params.macosTest + return env.BUILD_ON_MACOS != 'false' } } steps { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -571,7 +566,7 @@ pipeline { when { beforeAgent true expression { - return params.macosTest + return env.BUILD_ON_MACOS != 'false' } } steps { @@ -682,7 +677,7 @@ pipeline { when { beforeAgent true expression { - return params.macosTest + return env.BUILD_ON_MACOS != 'false' } } steps { @@ -754,7 +749,7 @@ pipeline { when { beforeAgent true expression { - return params.macosTest + return env.BUILD_ON_MACOS != 'false' } } steps { @@ -772,7 +767,7 @@ pipeline { when { beforeAgent true expression { - return params.macosTest + return env.BUILD_ON_MACOS != 'false' } } steps { @@ -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) } /** diff --git a/README.md b/README.md index f6f0bc6bbc87..d854b21af57a 100644 --- a/README.md +++ b/README.md @@ -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/