Skip to content
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

Merged
merged 11 commits into from
Jan 18, 2024

Conversation

zelinh
Copy link
Member

@zelinh zelinh commented Jan 13, 2024

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.

Copy link

codecov bot commented Jan 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b195cb2) 86.04% compared to head (74182be) 86.11%.

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.
📢 Have feedback on the report? Share it here.

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}"
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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}

Copy link
Member Author

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.

def prefixPath = "${WORKSPACE}/download"
def DISTRIBUTION_BUILD_NUMBER

if (args.incremental.equalsIgnoreCase("latest")) {
Copy link
Member

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.

Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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.

  1. This argument will be initiated in the jenkinsfile and incremental is straightforward stating what this parameter is for.
  2. 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

Copy link
Member

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.

Copy link
Member Author

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 Show resolved Hide resolved
vars/buildManifest.groovy Outdated Show resolved Hide resolved
def prefixPath = "${WORKSPACE}/download"
def DISTRIBUTION_BUILD_NUMBER

if (args.incremental.equalsIgnoreCase("latest")) {
Copy link
Member

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

@zelinh zelinh force-pushed the jenkins_incremental branch from 1d82df6 to d92cbeb Compare January 17, 2024 23:26

if (incremental_enabled) {
echo("Incremental build enabled! Retrieving previous build library.")
retrievePreviousBuild(args)
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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?

@zelinh zelinh force-pushed the jenkins_incremental branch from d92cbeb to d9b1d36 Compare January 18, 2024 00:02
Signed-off-by: Zelin Hao <[email protected]>
@zelinh zelinh force-pushed the jenkins_incremental branch from 0275f2b to 6e106d9 Compare January 18, 2024 00:35
Signed-off-by: Zelin Hao <[email protected]>
Copy link
Member

@gaiksaya gaiksaya left a 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?

@gaiksaya gaiksaya merged commit 8b7df12 into opensearch-project:main Jan 18, 2024
9 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 18, 2024
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>
@zelinh zelinh deleted the jenkins_incremental branch January 18, 2024 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants