-
Notifications
You must be signed in to change notification settings - Fork 5k
[CI] Optimise stash/unstash performance #18473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fbd8fb8
[CI] Optimise stash/unstash performance
v1v 86ac4c5
[CI] Use google storage
v1v 0ec32a7
ci: flatten files
v1v 1b612aa
ci: fix the permission denied after the unzip
v1v 04c2db7
ci: let's be explicit
v1v 44a5679
ci: zip does not compress the .git folder
v1v d4b1421
ci: fix the permission denied after the unzip
v1v 3563a8d
ci: use tar to support restore permissions
v1v df947c2
ci: fix the file changed as we read it
v1v 8dfa353
Revert "ci: fix the file changed as we read it"
v1v ba137ae
ci: fix the file changed as we read it
v1v 4a8ceec
Tweak some of the stash/unstash arguments
v1v aabc3de
ci: refactored with the shared library steps
v1v 0104e63
Update Jenkinsfile
v1v 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ pipeline { | |
| DOCKER_REGISTRY = 'docker.elastic.co' | ||
| AWS_ACCOUNT_SECRET = 'secret/observability-team/ci/elastic-observability-aws-account-auth' | ||
| RUNBLD_DISABLE_NOTIFICATIONS = 'true' | ||
| JOB_GCS_BUCKET = 'beats-ci-temp' | ||
| JOB_GCS_CREDENTIALS = 'beats-ci-gcs-plugin' | ||
| } | ||
| options { | ||
| timeout(time: 2, unit: 'HOURS') | ||
|
|
@@ -57,7 +59,7 @@ pipeline { | |
| pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ]) | ||
| deleteDir() | ||
| gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true) | ||
| stash allowEmpty: true, name: 'source', useDefaultExcludes: false | ||
| stashV2('source') | ||
| dir("${BASE_DIR}"){ | ||
| loadConfigEnvVars() | ||
| } | ||
|
|
@@ -722,7 +724,7 @@ def withBeatsEnv(boolean archive, Closure body) { | |
| "DOCKER_PULL=0", | ||
| ]) { | ||
| deleteDir() | ||
| unstash 'source' | ||
| unstashV2('source') | ||
| if(isDockerInstalled()){ | ||
| dockerLogin(secret: "${DOCKERELASTIC_SECRET}", registry: "${DOCKER_REGISTRY}") | ||
| } | ||
|
|
@@ -763,7 +765,7 @@ def withBeatsEnvWin(Closure body) { | |
| "RACE_DETECTOR=true", | ||
| ]){ | ||
| deleteDir() | ||
| unstash 'source' | ||
| unstashV2('source') | ||
| dir("${env.BASE_DIR}"){ | ||
| installTools() | ||
| try { | ||
|
|
@@ -1027,7 +1029,7 @@ def terraformCleanup(String stashName, String directory) { | |
| stage("Remove cloud scenarios in ${directory}"){ | ||
| withCloudTestEnv() { | ||
| withBeatsEnv(false) { | ||
| unstash "terraform-${stashName}" | ||
| unstash("terraform-${stashName}") | ||
|
Member
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. cosmetic change |
||
| retry(2) { | ||
| sh(label: "Terraform Cleanup", script: ".ci/scripts/terraform-cleanup.sh ${directory}") | ||
| } | ||
|
|
@@ -1176,7 +1178,7 @@ def runbld() { | |
| // Unstash the test reports | ||
| stashedTestReports.each { k, v -> | ||
| dir(k) { | ||
| unstash v | ||
| unstash(v) | ||
|
Member
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. cosmetic change |
||
| } | ||
| } | ||
| sh(label: 'Process JUnit reports with runbld', | ||
|
|
@@ -1190,3 +1192,44 @@ def runbld() { | |
| } | ||
| } | ||
| } | ||
|
|
||
| def stashV2(String name) { | ||
| def filename = "${name}.zip" | ||
| writeFile file: "${filename}", text: '' | ||
| def command = "tar --exclude=${filename} -czf ${filename} ." | ||
| if(isUnix()) { | ||
| sh(label: 'Archive', script: command) | ||
| } else { | ||
| bat(label: 'Archive', script: command) | ||
| } | ||
| googleStorageUpload( | ||
| bucket: "gs://${JOB_GCS_BUCKET}/${JOB_NAME}-${BUILD_NUMBER}/${name}", | ||
| credentialsId: "${JOB_GCS_CREDENTIALS}", | ||
| pattern: "${filename}", | ||
| sharedPublicly: false, | ||
| showInline: true | ||
| ) | ||
v1v marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if(isUnix()) { | ||
| sh(label: 'Delete zip', script: "rm ${filename}", returnStatus: true) | ||
| } else { | ||
| bat(label: 'Delete zip', script: "del ${filename}", returnStatus: true) | ||
| } | ||
| } | ||
|
|
||
| def unstashV2(String name) { | ||
| def filename = "${name}.zip" | ||
| def command = "tar -xpf ${filename}" | ||
| googleStorageDownload( | ||
| bucketUri: "gs://${JOB_GCS_BUCKET}/${JOB_NAME}-${BUILD_NUMBER}/${name}/${filename}", | ||
| credentialsId: "${JOB_GCS_CREDENTIALS}", | ||
v1v marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| localDirectory: '', | ||
| pathPrefix: "${JOB_NAME}-${BUILD_NUMBER}/${name}/" | ||
| ) | ||
| if(isUnix()) { | ||
| command += "; rm ${filename}" | ||
| sh(label: 'Extract', script: command) | ||
| } else { | ||
| bat(label: 'Extract', script: command) | ||
| bat(label: 'Delete zip', script: "del ${filename}", returnStatus: true) | ||
| } | ||
| } | ||
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.