From 2087d71936121bf9117c8e7ed467a46e5ecb316a Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 21 Oct 2021 12:23:58 +0100 Subject: [PATCH] CI: refactor the run e2e build (#28502) --- .ci/packaging.groovy | 34 ++++----------------------- Jenkinsfile | 35 ++++------------------------ x-pack/elastic-agent/Jenkinsfile.yml | 1 - 3 files changed, 10 insertions(+), 60 deletions(-) diff --git a/.ci/packaging.groovy b/.ci/packaging.groovy index 4f960aaf3cd..7c4ce7b5e8f 100644 --- a/.ci/packaging.groovy +++ b/.ci/packaging.groovy @@ -416,38 +416,14 @@ def runE2ETests(){ }; } - triggerE2ETests(suites) + runE2E(runTestsSuites: suites, + beatVersion: "${env.BEAT_VERSION}-SNAPSHOT", + gitHubCheckName: env.GITHUB_CHECK_E2E_TESTS_NAME, + gitHubCheckRepo: env.REPO, + gitHubCheckSha1: env.GIT_BASE_COMMIT) } } -def triggerE2ETests(String suite) { - echo("Triggering E2E tests for PR-${env.CHANGE_ID}. Test suites: ${suite}.") - - def branchName = isPR() ? "${env.CHANGE_TARGET}" : "${env.JOB_BASE_NAME}" - def e2eTestsPipeline = "e2e-tests/e2e-testing-mbp/${branchName}" - def beatVersion = "${env.BEAT_VERSION}-SNAPSHOT" - - def parameters = [ - booleanParam(name: 'forceSkipGitChecks', value: true), - booleanParam(name: 'forceSkipPresubmit', value: true), - booleanParam(name: 'notifyOnGreenBuilds', value: !isPR()), - string(name: 'BEAT_VERSION', value: beatVersion), - string(name: 'runTestsSuites', value: suite), - string(name: 'GITHUB_CHECK_NAME', value: env.GITHUB_CHECK_E2E_TESTS_NAME), - string(name: 'GITHUB_CHECK_REPO', value: env.REPO), - string(name: 'GITHUB_CHECK_SHA1', value: env.GIT_BASE_COMMIT), - ] - - build(job: "${e2eTestsPipeline}", - parameters: parameters, - propagate: false, - wait: false - ) - - def notifyContext = "${env.GITHUB_CHECK_E2E_TESTS_NAME}" - githubNotify(context: "${notifyContext}", description: "${notifyContext} ...", status: 'PENDING', targetUrl: "${env.JENKINS_URL}search/?q=${e2eTestsPipeline.replaceAll('/','+')}") -} - def withMacOSEnv(Closure body){ withEnvMask( vars: [ [var: "KEYCHAIN_PASS", password: getVaultSecret(secret: "secret/jenkins-ci/macos-codesign-keychain").data.password], diff --git a/Jenkinsfile b/Jenkinsfile index dd17073bc9f..d64020de940 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -541,7 +541,11 @@ def e2e(Map args = [:]) { if (args.e2e.get('entrypoint', '')?.trim()) { e2e_with_entrypoint(args) } else { - e2e_with_job(args) + runE2E(testMatrixFile: args.e2e?.get('testMatrixFile', ''), + beatVersion: "${env.VERSION}-SNAPSHOT", + gitHubCheckName: "e2e-${args.context}", + gitHubCheckRepo: env.REPO, + gitHubCheckSha1: env.GIT_BASE_COMMIT) } } @@ -576,35 +580,6 @@ def e2e_with_entrypoint(Map args = [:]) { } } -/** -* This method triggers the end 2 end testing job. -*/ -def e2e_with_job(Map args = [:]) { - def jobName = args.e2e?.get('job') - def testMatrixFile = args.e2e?.get('testMatrixFile', '') - def notifyContext = "e2e-${args.context}" - def e2eTestsPipeline = "${jobName}/${isPR() ? "${env.CHANGE_TARGET}" : "${env.JOB_BASE_NAME}"}" - - def parameters = [ - booleanParam(name: 'forceSkipGitChecks', value: true), - booleanParam(name: 'forceSkipPresubmit', value: true), - booleanParam(name: 'notifyOnGreenBuilds', value: !isPR()), - string(name: 'BEAT_VERSION', value: "${env.VERSION}-SNAPSHOT"), - string(name: 'testMatrixFile', value: testMatrixFile), - string(name: 'GITHUB_CHECK_NAME', value: notifyContext), - string(name: 'GITHUB_CHECK_REPO', value: env.REPO), - string(name: 'GITHUB_CHECK_SHA1', value: env.GIT_BASE_COMMIT), - ] - - build(job: "${e2eTestsPipeline}", - parameters: parameters, - propagate: false, - wait: false - ) - - githubNotify(context: "${notifyContext}", description: "${notifyContext} ...", status: 'PENDING', targetUrl: "${env.JENKINS_URL}search/?q=${e2eTestsPipeline.replaceAll('/','+')}") -} - /** * This method runs the given command supporting two kind of scenarios: * - make -C then the dir(location) is not required, aka by disaling isMage: false diff --git a/x-pack/elastic-agent/Jenkinsfile.yml b/x-pack/elastic-agent/Jenkinsfile.yml index 3e2155401c5..bda8cbdc684 100644 --- a/x-pack/elastic-agent/Jenkinsfile.yml +++ b/x-pack/elastic-agent/Jenkinsfile.yml @@ -96,7 +96,6 @@ stages: packaging-linux: "mage package" e2e: enabled: true - job: 'e2e-tests/e2e-testing-mbp' testMatrixFile: '.ci/.e2e-tests-for-elastic-agent.yaml' when: ## Customise when to run this subtask in the packaging stage. branches: false ## Only on a PR basis for the time being