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-42971] CpsScmFlowDefinition sends build to SCMFileSystem in … #577

Merged
merged 13 commits into from
Jan 4, 2023

Conversation

MartinKosicky
Copy link
Contributor

I added in CpsScmFlowDefinition (create) to send to lightweight checkout the build value into SCMFileSystem.of which is changed in jenkinsci/scm-api-plugin#160. The goal is to be able to expand branch value by build params if branch name contains for example ${BRANCH}

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Ought to include an integration test picking up jenkinsci/git-plugin#1305 and demonstrating effectiveness in solving the stated bug.

pom.xml Outdated Show resolved Hide resolved
pom.xml Outdated Show resolved Hide resolved
@MartinKosicky
Copy link
Contributor Author

MartinKosicky commented Aug 2, 2022

Ought to include an integration test picking up jenkinsci/git-plugin#1305 and demonstrating effectiveness in solving the stated bug.

Im planning to add integration test here and unit test in Git plugin

@MartinKosicky
Copy link
Contributor Author

Ought to include an integration test picking up jenkinsci/git-plugin#1305 and demonstrating effectiveness in solving the stated bug.

Done

@MartinKosicky
Copy link
Contributor Author

hmm, are these check fails related to this PR ?

@jglick
Copy link
Member

jglick commented Aug 4, 2022

are these check fails related to this PR ?

From a quick glance, looks like infrastructure problems with Windows agents; retriggered build.

@MartinKosicky MartinKosicky force-pushed the use_new_scp_api_lw_checkout branch 2 times, most recently from 1f065b7 to ea74d85 Compare August 5, 2022 05:13
@MartinKosicky
Copy link
Contributor Author

are these check fails related to this PR ?

From a quick glance, looks like infrastructure problems with Windows agents; retriggered build.

Now there is a bunch of
No test report files were found. Configuration error?
and
Caused: java.io.IOException: Remote call on JNLP4-connect connection from 20.102.0.182/20.102.0.182:11009 failed

:(

@jglick
Copy link
Member

jglick commented Aug 5, 2022

OK, that much seems to be fixed, sorry for the interruption. @dduportal FYI

@MartinKosicky
Copy link
Contributor Author

Ok this is testCase I was working on but not that test, hmm. Locally they were all sucesful. I will assume that I broke something?

@MartinKosicky MartinKosicky force-pushed the use_new_scp_api_lw_checkout branch 2 times, most recently from 5e5aea3 to 7239bbe Compare August 5, 2022 14:01
pom.xml Outdated Show resolved Hide resolved
@@ -115,7 +115,7 @@ public boolean isLightweight() {
Run<?,?> build = (Run<?,?>) _build;
String expandedScriptPath = build.getEnvironment(listener).expand(scriptPath);
if (isLightweight()) {
try (SCMFileSystem fs = SCMFileSystem.of(build.getParent(), scm)) {
try (SCMFileSystem fs = SCMFileSystem.of(build.getParent(), scm,null, build)) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
try (SCMFileSystem fs = SCMFileSystem.of(build.getParent(), scm,null, build)) {
try (SCMFileSystem fs = SCMFileSystem.of(build.getParent(), scm, null, build)) {

@jglick
Copy link
Member

jglick commented Aug 5, 2022

Edit docs: #329 (comment)

@MartinKosicky MartinKosicky marked this pull request as ready for review August 5, 2022 17:04
@MartinKosicky
Copy link
Contributor Author

MartinKosicky commented Aug 11, 2022

hmm, ill try to bump the versions?

@MartinKosicky
Copy link
Contributor Author

@jglick do you have any suggestion if I should bump the versions in git plugin? or what should we do here ?

@MartinKosicky
Copy link
Contributor Author

MartinKosicky commented Aug 11, 2022

When I import the incremental build of git plugin to my Idea, I see different versions than those that were specified in the incremental .pom file. Also the test seems to look at the pom definitions? Or I dont know where it knows the versions, but I see that maven loaded a different version than was generated in the .pom

@jglick
Copy link
Member

jglick commented Aug 11, 2022

When I import the incremental build of git plugin to my Idea, I see different versions

You may need to configure your IDE to honor

-Pconsume-incrementals
NetBeans does this automatically; I have no idea about IDEA (sorry for the pun). If in doubt, command-line mvn is authoritative.

Failed to load: Git plugin (git 4.12.0-rc4821.0fa_d6b_a_a_0928)
 - Update required: Jenkins Mailer Plugin (mailer 414.vcc4c33714601) to be updated to 435.v79ef3972b_5c7 or higher
 - Update required: Token Macro Plugin (token-macro 293.v283932a_0a_b_49) to be updated to 308.v4f2b_ed62b_b_16 or higher
 - Update required: Structs Plugin (structs 318.va_f3ccb_729b_71) to be updated to 324.va_f5d6774f3a_d or higher

possibly just means that this should subsume #574.

@MartinKosicky
Copy link
Contributor Author

Yes I am taking the incrementals, i saw this behaviour also in mvn dependency tree to confirm.

@MartinKosicky
Copy link
Contributor Author

MartinKosicky commented Dec 16, 2022

hmm the build seemed to completely change , now i have to figure out how to build this thing in idea :(

ok i seemed to broke the history by some dump rebase , eh

pom.xml Outdated Show resolved Hide resolved
pom.xml Outdated Show resolved Hide resolved
fix newline

Co-authored-by: Devin Nusbaum <[email protected]>
@MartinKosicky MartinKosicky marked this pull request as ready for review December 16, 2022 20:26
@MartinKosicky MartinKosicky requested a review from a team as a code owner December 16, 2022 20:26
@MartinKosicky
Copy link
Contributor Author

I think it shouls be ok now

@MartinKosicky
Copy link
Contributor Author

@MarkEWaite hello, will you have time so we can finalize these 3 PRs. This one is the last and I think you also tested this already when we were working with the git-scm

@MarkEWaite
Copy link
Contributor

I've added it to the plugins.txt file that I'm using for my testing of git plugin 5.0.0 and git client plugin 4.0.0. I'll include the details of JENKINS-42971 in my testing.

@MarkEWaite
Copy link
Contributor

I've confirmed that the incremental release of this pull request resolves JENKINS-42971. I tested with the git plugin 5.0.0 pre-release and the git client plugin 4.0.0 pre-release.

Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

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

Thanks! Approved

@MartinKosicky
Copy link
Contributor Author

Thanks! Approved

Thank you :). Hmm just a quick question, how does the merging process work here? Who will merge this or we need more approvals?

@MarkEWaite
Copy link
Contributor

Thanks! Approved

Thank you :). Hmm just a quick question, how does the merging process work here? Who will merge this or we need more approvals?

One of the maintainers needs to merge it. Since two of them have approved the pull request, I believe it is ready for merge. Once it is merged, the continuous delivery process will release a new version of the plugin.

@basil
Copy link
Member

basil commented Dec 21, 2022

Note that in this project, being ready for merge is no guarantee that a pull request will be merged in a timely fashion. I routinely file PRs that are approved by maintainers with the green checkmark yet remain unmerged (and therefore unreleased) for an extended period of time.

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Seems OK though I have not followed details recently. @dwnusbaum was most recently reviewing seriously; not sure if he is around to check latest changes.

def.setLightweight(true);
p.setDefinition(def);

r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("BRANCH", "master2"))));
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 mean to also assert that it actually loaded the specified revision of flow.groovy, for example by checking the altered message?

Copy link
Member

Choose a reason for hiding this comment

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

FTR with main reverted, the failure is as expected

java.lang.AssertionError: 
unexpected build status; build log was:
------
Started
hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune -- origin +refs/heads/${BRANCH}:refs/remotes/origin/${BRANCH}" returned status code 128:
stdout: 
stderr: fatal: couldn't find remote ref refs/heads/${BRANCH}

	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2734)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2111)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:87)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:623)
	at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:406)
	at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:219)
	at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:191)
	at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:174)
	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:118)
	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:70)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:312)
	at hudson.model.ResourceController.execute(ResourceController.java:107)
	at hudson.model.Executor.run(Executor.java:449)
Finished: FAILURE

------

Expected: is <SUCCESS>
     but: was <FAILURE>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.jvnet.hudson.test.JenkinsRule.assertBuildStatus(JenkinsRule.java:1438)
	at org.jvnet.hudson.test.JenkinsRule.assertBuildStatus(JenkinsRule.java:1444)
	at org.jvnet.hudson.test.JenkinsRule.assertBuildStatusSuccess(JenkinsRule.java:1472)
	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinitionTest.lightweight_brach_parametrised(CpsScmFlowDefinitionTest.java:222)

Would just be nice to strengthen the test to prove that it was really running from the correct branch, and not merely that the build passed.

Copy link
Contributor Author

@MartinKosicky MartinKosicky Dec 28, 2022

Choose a reason for hiding this comment

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

Hmm but on 4th august you wrote that :

jglick on Aug 4
Probably a more straightforward way to assert this. Or just delete entirely—the fact that the build ran at all (when the repo only contains the master2 branch) is proof enough that the fix worked, right?

I was parsing the log output before, or did i misunderstood the conversation before...

Copy link
Member

Choose a reason for hiding this comment

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

Sigh, this is what happens when months go by between review comments. Fine enough as it is.

@dwnusbaum
Copy link
Member

@dwnusbaum was most recently reviewing seriously

No, my recent review was just to try to help resolve #577 (comment) and a bad merge related to #612, which is something I worked on. I have not looked at this PR beyond that.

@MarkEWaite
Copy link
Contributor

I found no issues related to this change in my testing of git plugin 5.0.0 and git client plugin 4.0.0. I would like to see it merged and released. Thanks for your patience @MartinKosicky !

MarkEWaite added a commit to MarkEWaite/docker-lfs that referenced this pull request Dec 30, 2022
MarkEWaite added a commit to MarkEWaite/docker-lfs that referenced this pull request Jan 1, 2023
Does not include the expansion of environment variables in lightweight
checkout.

jenkinsci/workflow-cps-plugin#577 is the
lightweight checkout pull request.
@jglick jglick enabled auto-merge January 3, 2023 22:51
@jglick jglick merged commit 9b36ad9 into jenkinsci:master Jan 4, 2023
@MartinKosicky
Copy link
Contributor Author

Thank you :)

@jglick
Copy link
Member

jglick commented Jan 4, 2023

Thank you for driving this forward and for your patience.

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.

6 participants