Skip to content

Commit

Permalink
CI: refactor the run e2e build (elastic#28502)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored and wiwen committed Nov 1, 2021
1 parent 2dd2eb6 commit 2087d71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 60 deletions.
34 changes: 5 additions & 29 deletions .ci/packaging.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
35 changes: 5 additions & 30 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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 <folder> then the dir(location) is not required, aka by disaling isMage: false
Expand Down
1 change: 0 additions & 1 deletion x-pack/elastic-agent/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2087d71

Please sign in to comment.