feat(pipeline): retrieve prep from archive if it exists - #7079
Conversation
3f5c63e to
4d2e419
Compare
| if (buildNumber == 1) { | ||
| echo "[INFO] First build of ${jobName}, no ${archiveName} available yet" | ||
| } else { | ||
| // Loop over builds to retrieve the prep archive as previous build can have (only) other archive(s) |
There was a problem hiding this comment.
Maybe use lastSuccessfulBuild (note that this includes UNSTABLE) rather than looping?
There was a problem hiding this comment.
The issue with lastSuccessFulBuild is that I would not be able to retrieve the bom-report from an "unstable" build (one with a marker for example).
There was a problem hiding this comment.
FWIW, I got it looping over more than 100 builds in less than a second in #7037, I was surprised how quick it can be.
There was a problem hiding this comment.
The issue with
lastSuccessFulBuildis that I would not be able to retrieve the bom-report from an "unstable" build
Why? These would match lastSuccessfulBuild (not lastStableBuild).
There was a problem hiding this comment.
I got it looping over more than 100 builds in less than a second
Sure, if they are already loaded into memory! The problem is the case that the SoftReferences have been cleared and you are forcing large objects to reread from disk.
There was a problem hiding this comment.
Would you consider this a blocker?
There was a problem hiding this comment.
I could probably use something like a S3 archive, but that would require some non trivial infra setup as we're trying to avoid write credentials on ci.jenkins.io as it can't be 100% trusted.
There was a problem hiding this comment.
And I'm counting later on on this trick to retrieve the bom report across previous builds too.
There was a problem hiding this comment.
Would you consider this a blocker?
Probably not, just caught my eye and alarmed me: in general, any code which loops over historical (completed) build records should be a red flag.
There was a problem hiding this comment.
During my (numerous) tests I tried several selectors, but as a build could have archived something else, copyArtifact would use that build as ref to find the archive I wanted, archive not always in that build, sometime in earlier ones. Hence this loop.
I may have missed something, but I'd like to start that way if possible. Let me know if you think of an alternative 🙂
loops over historical (completed) build records should be a red flag
I need to do this to be able to rerun multiple builds profiting from the last available prep:
- Build n°1, initial commit: run
bash prep.shand create new archive, archiveArtifact it, publish other artifacts (like test reports) - Build n°2, replay or rerun: retrieve archive from build n°1, don't create new archive, publish other artifacts
- Build n°3, replay or rerun: retrieve archive from build n°1, ...
- Build n° 4, new commit: run
bash prep.shand create new archive, archiveArtifact it, publish other artifacts - Build n°5, replay or rerun: retrieve archive from build n°4, ...
- Build n°6, replay or rerun: retrieve archive from build n°4, ...
- etc.
|
I'd like to merge this PR and #7077 as soon as possible, as they'll help me quite a lot to pursue my #7037 split (cf #7073, for jenkins-infra/helpdesk#5208) without having to rerun build executing prep.sh on (too) many plugins everytime in multiple PRs, and as this one will result in immediate costs reductions. |
lemeurherve
left a comment
There was a problem hiding this comment.
Completed a bit the PR body and added more explanatory comments below.
Merging to benefit from immediate costs reductions and to allow me to iterate more quickly on jenkins-infra/helpdesk#5208 and #7037 split.
I'll address any post-merge suggestion in follow-up pull request(s) if needed.
| if (junit(testResults: '**/target/surefire-reports/TEST-*.xml,**/target/failsafe-reports/TEST-*.xml').failCount > 0) { | ||
| error 'Some test failures during prep.sh, not going to continue' | ||
| } |
There was a problem hiding this comment.
Moved from mavenNode, we want to stop here if there is an error in prep.sh.
| error 'Some test failures during prep.sh, not going to continue' | ||
| } | ||
| // Publish incrementals before prep archive preparation to avoid dirty git status | ||
| infra.prepareToPublishIncrementals() |
There was a problem hiding this comment.
Moved from the end of "prep" stage as we can prepare incrementals publication as soon as prep.sh finished, and before dirtying the staging area when we create the new prep archive.
| catchError(buildResult: 'SUCCESS', stageResult: 'NOT_BUILT') { | ||
| error("[INFO] ${prepArchiveName} not found") | ||
| } | ||
| return |
There was a problem hiding this comment.
Mark stage as skipped.
|
|
||
| stage('prep') { | ||
| if (prepFoundInBuildNumber == 0) { | ||
| withChecks(name: 'Tests', includeStage: true) { |
There was a problem hiding this comment.
withCheck moved from mavenNode to here and to L182, as those are the parts we want to record test results from. (Also, avoid dangling GitHub status checks when skipping stages inside mavenNode)
| def fullTestLabel = pullRequest.labels.contains('full-test') | ||
| def weeklyTestLabel = pullRequest.labels.contains('weekly-test') |
There was a problem hiding this comment.
Common location for labels retrieval, quite useful when using replays to reproduce/trigger certain type of builds.
Note: hotfixed in 84e4da8
-def fullTestLabel = pullRequest.labels.contains('full-test')
-def weeklyTestLabel = pullRequest.labels.contains('weekly-test')
+def fullTestLabel
+def weeklyTestLabel
+if (env.CHANGE_ID) {
+ fullTestLabel = pullRequest.labels.contains('full-test')
+ weeklyTestLabel = pullRequest.labels.contains('weekly-test')
+}
Rollbacked for now in #7089 Ref: |
This change allows to skip
bash prep.shif there is an archive including the same commit as the one built, gaining about 30 minutes on every subsequent builds using (or set in replay viafixedPrepArchiveNameto) the same commit.Using a
copyArtifactsloop over previous builds as I need to retrieve the archive corresponding to the current commit, not necessary the last one:archiveArtifactsit, publish other artifacts (like test reports)archiveArtifactsit, publish other artifactsetc.
Extracted from:
Refs:
Testing done
CI
First build in 34 mins: https://ci.jenkins.io/job/Tools/job/bom/view/change-requests/job/PR-7079/2
Second build in 32 mins with a new commit
4d2e41948de74ee9ac52f8b372df2c109530a3f3, creating a new archive as expected: https://ci.jenkins.io/job/Tools/job/bom/job/PR-7079/3Third build in 2 mins 24 sec, rerun with "Build now" without any pipeline or code change: https://ci.jenkins.io/job/Tools/job/bom/job/PR-7079/4
Fourth build, using
fixedPrepArchiveNamefrom the first build and showing a warning: https://ci.jenkins.io/job/Tools/job/bom/job/PR-7079/7Not marking the build as instable in that case as a PR where changes have been made to a pipeline only could still reuse a prep archived from an earlier build.
Submitter checklist