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

[JENKINS-48431] Support both lightweight checkout AND build parameters #78

Closed
wants to merge 4 commits into from

Conversation

tgatinea
Copy link

@tgatinea tgatinea commented Oct 14, 2019

JENKINS-48431 To support both lightweight checkout AND build parameters, we need to:

  • recover the environment parameters of the build
  • evaluate the SCM structure according to the build environment parameters

This leads to implement a new method :

public static SCMFileSystem of(@nonnull Run build, @nonnull SCM scm, @checkfornull SCMRevision rev)

This new method offer the capacity to recover the environments parameter of the build as the current build is propagated through the new method.

Note that this modification is in relation with two other pull requests that concerns:

@tgatinea tgatinea changed the title JENKINS-48431 Support both lightweight checkout AND build parameters [JENKINS-48431](https://issues.jenkins-ci.org/browse/JENKINS-48431) Support both lightweight checkout AND build parameters Oct 15, 2019
@tgatinea tgatinea changed the title [JENKINS-48431](https://issues.jenkins-ci.org/browse/JENKINS-48431) Support both lightweight checkout AND build parameters [JENKINS-48431] Support both lightweight checkout AND build parameters Oct 15, 2019
@tgatinea
Copy link
Author

@bitwiseman Could you have a look? Thanks by advance

@bitwiseman
Copy link
Contributor

@tgatinea Does this have downstream changes in the github-branch-source-plugin?
What would they look like?
Have you tried creating a draft PR to that repo using the incremental from this one?

Copy link
Contributor

@bitwiseman bitwiseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also wondering if some other methods need to be deprecated?

* @throws InterruptedException if the attempt to create a {@link SCMFileSystem} was interrupted.
*/
@CheckForNull
public static SCMFileSystem of(@NonNull Run build, @NonNull SCM scm, @CheckForNull SCMRevision rev)
Copy link
Contributor

@bitwiseman bitwiseman Nov 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so there's an Item owner version of this and Run build version.
It looks like most of this method is identical to Run build version. Would it make sense to have a common private method that they call into that calls the appropriate b.build() depending on type?

Copy link
Member

@jetersen jetersen May 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to think of a good way to try and deduplicate this code without much success as both supports and builder.build has multiple implementations.

Yes Run does implement Item however I am unsure how to the write method to deduplicate.
as supports has several more implementations and of also includes SCMSource.class, SCMHead.class

@tgatinea
Copy link
Author

@tgatinea Does this have downstream changes in the github-branch-source-plugin?
What would they look like?
Have you tried creating a draft PR to that repo using the incremental from this one?

@bitwiseman I made no change on the github-branch-source-plugin.

I introduce the new "public SCMFileSystem build(@nonnull Run build, ..." and "public static SCMFileSystem of(@nonnull Run build,..." because of the "lightweight checkout" functionality does not work if parameters are set into the SCM configuration (e.g. ${GERRIT_REFSPEC} in the refspec).
Currently the "lightweight checkout" leads to use "public static SCMFileSystem of(@nonnull Item owner, ..." and "public SCMFileSystem build(@nonnull Item owner, ...".
But I was not able to recover the environment parameters from "Item owner".
That's why I change to pass the "Run build" instead of the "Item owner" because I was able to recover the environment parameters associated to "Run build" object.

I use the SCM git, that's where I have coded the evaluation of the environment parameters (See git-plugin: jenkinsci/git-plugin#772)

As I have added new method to the class, I guess that I don't have any impact on github-branch-source-plugin.
But I may have not understood your question.

Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall idea of the change seems ok, but right now there is a breaking change, which is not ok for a widely-used plugin like this.

src/main/java/jenkins/scm/api/SCMFileSystem.java Outdated Show resolved Hide resolved
@jetersen
Copy link
Member

@tgatinea not sure whether your still active or if you would prefer if I opened a new PR to the main repo.
So I started with a PR to your repo. Please see tgatinea#1 and feel free to merge it.

@tgatinea
Copy link
Author

@jetersen I'm not familiar with the process to deliver into master branch.
Do I need to do something more ?

@jetersen
Copy link
Member

No, now we play the waiting game once again 😅

@jetersen
Copy link
Member

@dwnusbaum @bitwiseman any chance we can land this to get the ball going?

@dwnusbaum dwnusbaum self-requested a review June 29, 2020 14:04
Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current state looks good to me, and I glanced at the downstream PRs that use the new API and they look fine conceptually as well. Do the consumer or implementation guides need to be updated? I didn't see anything obvious, but would be good to double-check. Would it be useful to add tests here for any of the new methods? I checked for existing tests that exercise SCMFileSystem.build or SCMFileSystem.of but did not see any, but maybe could be useful to at least test that SCMFileSystem.build(Run, ...) uses SCMFileSystem.build(Item, ...) as a default implementation.

@dwnusbaum dwnusbaum requested a review from bitwiseman July 2, 2020 19:09
@bitwiseman
Copy link
Contributor

@tgatinea @jetersen
Devin asked some questions. Any response?

@bitwiseman
Copy link
Contributor

@tgatinea @jetersen
Ping?

@res0nance
Copy link

This is useful and I am interested in this, is anyone planning on moving this forward?
What other pieces are required here?
I could add the corresponding test, if that is what it takes to get this moving.

@jglick jglick marked this pull request as draft January 7, 2022 13:41
@gserre
Copy link

gserre commented Jul 8, 2022

@jetersen,
working with @tgatinea who leaves the company, I'm looking at tickets related to "lightweight checkout +build parameters" he has created because of CI issue on our side.
This "lightweight checkout +build parameters" issue results to 3 tickets: git + scm-api + worlflow-cps
Our CI issue was solved via plugins: git 4.3.0-SNAPSHOT + scm-api 2.6.4-SNAPSHOT + workflow-cps 2.81-SNAPSHOT.

Today, I have installed latest plugin version, and the problem is back ...
Looking at the plugin content of these latest versions:

can you give me more information/status about this "old" ticket ?
thx

@jglick
Copy link
Member

jglick commented Aug 1, 2022

Is this related to #160?

@jetersen
Copy link
Member

jetersen commented Aug 1, 2022

Yes @jglick

@dwnusbaum
Copy link
Member

I think this is irrelevant now that #160 has been merged, so I am closing it.

@dwnusbaum dwnusbaum closed this Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants