-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add a new groovy library to download the previous build artifacts #362
Add a new groovy library to download the previous build artifacts #362
Conversation
Signed-off-by: Zelin Hao <[email protected]>
Signed-off-by: Zelin Hao <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #362 +/- ##
============================================
+ Coverage 86.04% 86.11% +0.06%
Complexity 29 29
============================================
Files 81 82 +1
Lines 215 216 +1
Branches 12 12
============================================
+ Hits 185 186 +1
Misses 22 22
Partials 8 8 ☔ View full report in Codecov by Sentry. |
vars/retrievePreviousBuild.groovy
Outdated
def lib = library(identifier: 'jenkins@jenkins_incremental', retriever: legacySCM(scm)) | ||
def inputManifestObj = lib.jenkins.InputManifest.new(readYaml(file: args.inputManifest)) | ||
|
||
def DISTRIBUTION_JOB_NAME = "${JOB_NAME}" |
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.
Do you need to ensure it is the correct job name?
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.
Or just use the lib call to parse as arg?
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.
This works in the beta jenkins. Should be enough to get the correct job name as we are doing the same in multiple places. e.g.
"JOB_NAME=${JOB_NAME}", |
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.
This will take any job name where this is run? If someone wants runs this lib in another job, this might cause issue. Take it as an optional arg and default to ${JOB_NAME}
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.
@gaiksaya Done in the latest commit.
vars/retrievePreviousBuild.groovy
Outdated
def prefixPath = "${WORKSPACE}/download" | ||
def DISTRIBUTION_BUILD_NUMBER | ||
|
||
if (args.incremental.equalsIgnoreCase("latest")) { |
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.
Can this arg incremental
being changed to version
? As the value is either the version or latest
.
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.
or maybe be incrementally_build_id
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.
It's not really the version but the previous build ID.
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.
Then prev_build_id might be a good fit here.
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.
But this is the argument we would get from buildManifest
groovy library. It could also be false
there not just a simple id.
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.
Since empty/null/false are all same in this case, previous_build_id
seems good fit. How about replacing false
with none/null
here? or @peterzhuamazon may have better ideas?
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.
I would like to keep it as the original incremental
name for the argument.
- This argument will be initiated in the jenkinsfile and incremental is straightforward stating what this parameter is for.
- This parameter will work as a dynamic option for user: enable/disable the incremental build process; if enable, give user option to choose what particular build artifacts to download. Since using Jenkins dynamic parameter is a little complicated, I lean on to name it more generic.
What do you think? @gaiksaya @peterzhuamazon
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.
You can add that customization in main distribution file. When it comes to this specific library, you need a previous build id which needs to be mentioned explicitly. Still leaning toward previous_build_id
for this specific library. How you showcase that at the distribution pipeline level can be different that this.
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.
Updated the PR with two separate parameters. One is a boolean for whether we enable incremental build; this will be used in buildManifest
lib to determine whether trigger incremental build. The other is the generic one build ID to download previous build used in retrievePreviousBuild
library. Please take a look. Thanks. @gaiksaya @peterzhuamazon
vars/retrievePreviousBuild.groovy
Outdated
def prefixPath = "${WORKSPACE}/download" | ||
def DISTRIBUTION_BUILD_NUMBER | ||
|
||
if (args.incremental.equalsIgnoreCase("latest")) { |
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.
or maybe be incrementally_build_id
Signed-off-by: Zelin Hao <[email protected]>
Signed-off-by: Zelin Hao <[email protected]>
Signed-off-by: Zelin Hao <[email protected]>
Signed-off-by: Zelin Hao <[email protected]>
1d82df6
to
d92cbeb
Compare
|
||
if (incremental_enabled) { | ||
echo("Incremental build enabled! Retrieving previous build library.") | ||
retrievePreviousBuild(args) |
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 arg previousBuildId
is not passed here.
Is the default latest
here?
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.
It will be passed from the arguments of this class right? The default latest is assigned when we declare the parameter.
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.
Since the default is pointing to latest we should be good but if not, whoever calls this lib needs to provide args.previousBuildId
. Not sure what is the best approach. Maybe mentioning in the comments above?
Signed-off-by: Zelin Hao <[email protected]>
d92cbeb
to
d9b1d36
Compare
Signed-off-by: Zelin Hao <[email protected]>
0275f2b
to
6e106d9
Compare
Signed-off-by: Zelin Hao <[email protected]>
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.
@peterzhuamazon Maybe take another look?
Signed-off-by: Zelin Hao <[email protected]> (cherry picked from commit 8b7df12) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
Add a new groovy library to download the previous build artifacts intended to be used for incremental build.
Issues Resolved
Part of opensearch-project/opensearch-build#4292
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.