From 36c32b6466bc225c25259cac266c5eed17840e9f 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) (cherry picked from commit fef612910c578f07a99b71e49cf6f68e9737518b) --- .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 91853fa3a1a..8af18c0dd4d 100644 --- a/.ci/packaging.groovy +++ b/.ci/packaging.groovy @@ -410,38 +410,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 2b318dfbb50..e50fd1aa3a4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -524,7 +524,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) } } @@ -559,35 +563,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