This repository was archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
feat: support passing KIBANA_VERSION #905
Merged
mdelapenya
merged 26 commits into
elastic:master
from
mdelapenya:901-support-kibana-prs
Apr 12, 2021
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
9cc4354
chore: support returning different fallback Docker namespaces
mdelapenya dc66cf6
chore: add KIBANA_VERSION variable
mdelapenya 1a0e5a8
docs: document new Kibana variable
mdelapenya 052fcc1
Merge branch 'master' into 901-support-kibana-prs
mdelapenya c5ae22a
Merge branch 'master' into 901-support-kibana-prs
mdelapenya 7b829f7
chore(ci): add regular to pipeline for Kibana PRs
mdelapenya c70fe33
chore: only process kibana events
mdelapenya 86f90a9
chore: add PR author to the cause string
mdelapenya 20c92ba
chore: print PR sha in cause string
mdelapenya 744288b
chore: update Generic Trigger to match existing example
mdelapenya f1e360a
chore: support manually running the tests for a PR
mdelapenya 326e46d
chore: do not notify on slack on build greens
mdelapenya 8cc717e
fix: rename JJB as it's not a multibranch pipeline
mdelapenya a7212f4
Merge branch 'master' into 901-support-kibana-prs
mdelapenya 5b31039
feat: build kibana image based on the PR or the UI params
mdelapenya 0f9cae9
chore: simplify triggering the pipeline from the UI
mdelapenya f66cfa0
chore: simplify even more
mdelapenya c634d5f
chore: use stackVersion if kibana version is not set
mdelapenya 071f7cc
docs: update docs about KIBANA_VERSION
mdelapenya 14c5124
chore: rename variable
mdelapenya 870f666
chore: rename job
mdelapenya 500f683
fix: misleading param description
mdelapenya 4422597
fix: set the proper Docker namespace for Kibana
mdelapenya b40f5a9
Merge branch 'master' into 901-support-kibana-prs
mdelapenya 72c1c37
Merge branch 'master' into 901-support-kibana-prs
mdelapenya 7e6af36
Merge branch 'master' into 901-support-kibana-prs
mdelapenya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| #!/usr/bin/env groovy | ||
|
|
||
| @Library('apm@current') _ | ||
|
|
||
| pipeline { | ||
| agent none | ||
| environment { | ||
| REPO = 'kibana' | ||
| BASE_DIR = "src/github.com/elastic/${env.REPO}" | ||
| GITHUB_CHECK_E2E_TESTS_NAME = 'E2E Tests' | ||
| PIPELINE_LOG_LEVEL = "INFO" | ||
| } | ||
| options { | ||
| timeout(time: 3, unit: 'HOURS') | ||
| buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30')) | ||
| timestamps() | ||
| ansiColor('xterm') | ||
| disableResume() | ||
| durabilityHint('PERFORMANCE_OPTIMIZED') | ||
| disableConcurrentBuilds() | ||
| } | ||
| // http://JENKINS_URL/generic-webhook-trigger/invoke | ||
| // Pull requests events: https://docs.github.com/en/developers/webhooks-and-events/github-event-types#pullrequestevent | ||
| triggers { | ||
| GenericTrigger( | ||
| genericVariables: [ | ||
| [key: 'GT_REPO', value: '$.repository.full_name'], | ||
| [key: 'GT_BASE_REF', value: '$.pull_request.base.ref'], | ||
| [key: 'GT_PR', value: '$.issue.number'], | ||
| [key: 'GT_PR_HEAD_SHA', value: '$.pull_request.head.sha'], | ||
| [key: 'GT_BODY', value: '$.comment.body'], | ||
| [key: 'GT_COMMENT_ID', value: '$.comment.id'] | ||
| ], | ||
| genericHeaderVariables: [ | ||
| [key: 'x-github-event', regexpFilter: 'comment'] | ||
| ], | ||
| causeString: 'Triggered on comment: $GT_BODY', | ||
| printContributedVariables: false, | ||
| printPostContent: false, | ||
| silentResponse: true, | ||
| regexpFilterText: '$GT_REPO$GT_BODY', | ||
| regexpFilterExpression: '^elastic/kibana/run-fleet-e2e-tests$' | ||
| ) | ||
| } | ||
| parameters { | ||
| string(name: 'kibana_pr', defaultValue: "master", description: "PR ID to use to build the Docker image. (e.g 10000)") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are simplifying the manual trigger: simply use the PR ID, without |
||
| } | ||
| stages { | ||
| stage('Process GitHub Event') { | ||
| steps { | ||
| checkPermissions() | ||
| buildKibanaDockerImage(refspec: getBranch()) | ||
| catchError(buildResult: 'UNSTABLE', message: 'Unable to run e2e tests', stageResult: 'FAILURE') { | ||
| runE2ETests('fleet') | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| def checkPermissions(){ | ||
| if(env.GT_PR){ | ||
| if(!githubPrCheckApproved(changeId: "${env.GT_PR}", org: 'elastic', repo: 'kibana')){ | ||
| error("Only PRs from Elasticians can be tested with Fleet E2E tests") | ||
| } | ||
|
|
||
| if(!hasCommentAuthorWritePermissions(env.GT_PR, env.GT_COMMENT_ID)){ | ||
| error("Only Elasticians can trigger Fleet E2E tests") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| def getBranch(){ | ||
| if(env.GT_PR){ | ||
| return "PR/${env.GT_PR}" | ||
| } | ||
|
|
||
| return "PR/${params.kibana_pr}" | ||
| } | ||
|
|
||
| def getDockerTag(){ | ||
| if(env.GT_PR){ | ||
| return "${env.GT_PR_HEAD_SHA}" | ||
| } | ||
|
|
||
| // we are going to use the 'pr12345' tag | ||
| return "pr${params.kibana_pr}" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Docker tag generated by the kibanaDockerBuild step builds and pushes the |
||
| } | ||
|
|
||
| def hasCommentAuthorWritePermissions(prId, commentId){ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potentially reuse elastic/apm-pipeline-library#1064 |
||
| def repoName = "elastic/kibana" | ||
| def token = getGithubToken() | ||
| def url = "https://api.github.com/repos/${repoName}/issues/${prId}/comments/${commentId}" | ||
| def comment = githubApiCall(token: token, url: url, noCache: true) | ||
| def json = githubRepoGetUserPermission(token: token, repo: repoName, user: comment?.user?.login) | ||
|
|
||
| return json?.permission == 'admin' || json?.permission == 'write' | ||
| } | ||
|
|
||
| def runE2ETests(String suite) { | ||
| log(level: 'DEBUG', text: "Triggering '${suite}' E2E tests for PR-${env.GT_PR}.") | ||
|
|
||
| // Kibana's maintenance branches follow the 7.11, 7.12 schema. | ||
| def branchName = "${env.GT_BASE_REF}.x" | ||
| def e2eTestsPipeline = "e2e-tests/e2e-testing-mbp/${branchName}" | ||
|
|
||
| def parameters = [ | ||
| booleanParam(name: 'forceSkipGitChecks', value: true), | ||
| booleanParam(name: 'forceSkipPresubmit', value: true), | ||
| booleanParam(name: 'notifyOnGreenBuilds', value: false), | ||
| booleanParam(name: 'BEATS_USE_CI_SNAPSHOTS', value: true), | ||
| 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: 'KIBANA_VERSION', value: getDockerTag()), | ||
| ] | ||
|
|
||
| build(job: "${e2eTestsPipeline}", | ||
| parameters: parameters, | ||
| propagate: false, | ||
| wait: false | ||
| ) | ||
|
|
||
| /* | ||
| // commented out to avoid sending Github statuses to Kibana PRs | ||
| def notifyContext = "${env.pr_head_sha}" | ||
| githubNotify(context: "${notifyContext}", description: "${notifyContext} ...", status: 'PENDING', targetUrl: "${env.JENKINS_URL}search/?q=${e2eTestsPipeline.replaceAll('/','+')}") | ||
| */ | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --- | ||
| - job: | ||
| name: e2e-tests/e2e-testing-kibana-fleet | ||
| display-name: Fleet UI e2e tests Pipeline | ||
| description: Jenkins pipeline to run the end2end tests for the Fleet UI | ||
| project-type: pipeline | ||
| disabled: false | ||
| pipeline-scm: | ||
| script-path: .ci/e2eKibana.groovy | ||
| scm: | ||
| - git: | ||
| url: git@github.com:elastic/e2e-testing.git | ||
| refspec: +refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pr/* | ||
| wipe-workspace: 'True' | ||
| name: origin | ||
| shallow-clone: true | ||
| credentials-id: f6c7695a-671e-4f4f-a331-acdce44ff9ba | ||
| reference-repo: /var/lib/jenkins/.git-references/e2e-testing.git | ||
| branches: | ||
| - $branch_specifier |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command to run the tests in Kibana would be
/run-fleet-e2e-testsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EricDavisX this pipeline represents the way to interact with Kibana PRs. Will document it, but:
/run-fleet-e2e-tests. Only for elasticians