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-58716] Support checking out plugins with Incremental versions #181

Merged
merged 5 commits into from
Sep 18, 2019

Conversation

basil
Copy link
Member

@basil basil commented Aug 1, 2019

See JENKINS-58716. Observed in jenkinsci/bom#53. The problem and solution are described well in the bug. The rest is just a small matter of programming.

@basil
Copy link
Member Author

basil commented Aug 1, 2019

Looks like this wasn't just a small matter of programming after all! When testing out this fix over at jenkinsci/bom#53, I got this error:

org.jenkins.tools.test.exception.PluginSourcesUnavailableException: Problem while checking out plugin sources!
	at org.jenkins.tools.test.PluginCompatTester.testPluginAgainst(PluginCompatTester.java:476)
	at org.jenkins.tools.test.PluginCompatTester.testPlugins(PluginCompatTester.java:299)
	at org.jenkins.tools.test.PluginCompatTesterCli.main(PluginCompatTesterCli.java:164)
Caused by: java.lang.RuntimeException: The git-checkout command failed. || Cloning into '/home/basil/work/third-party/jenkinsci/bom/target/local-test/pct-work/git-server'...
From git://github.com/jenkinsci/git-server-plugin
 * branch            HEAD       -> FETCH_HEAD
fatal: reference is not a tree: 303f29958f6165e96fe689bd85fea2b2db457100

	at org.jenkins.tools.test.PluginCompatTester.cloneFromSCM(PluginCompatTester.java:560)
	at org.jenkins.tools.test.PluginCompatTester.testPluginAgainst(PluginCompatTester.java:462)
	... 2 more

Evaluating this further, the problem is that the tag 303f29958f6165e96fe689bd85fea2b2db457100 exists in my fork basil/git-server-plugin but not the upstream repository jenkinsci/git-server-plugin. However, the POM in the incremental build has a <connection> value of jenkinsci/git-server-plugin, not my fork:

  <scm>
    <connection>scm:git:git://github.com/jenkinsci/git-server-plugin.git</connection>
    <developerConnection>scm:git:git@github.com:jenkinsci/git-server-plugin.git</developerConnection>
    <tag>303f29958f6165e96fe689bd85fea2b2db457100</tag>
    <url>https://github.com/jenkinsci/git-server-plugin</url>
  </scm>

I reproduced the error calling cloneFromSCM in my IDE and found that changing the value of <connection> from scm:git:git://github.com/jenkinsci/git-server-plugin.git to scm:git:git://github.com/basil/git-server-plugin.git fixed the problem.

Based on this evaluation, I think the change in this PR is makes the situation no worse for non-incremental builds and is necessary but not sufficient for fixing JENKINS-58716 for incremental builds. Therefore I think we should go ahead with this PR. Once this PR has been merged, I think the next step would be to fix the incrementals subsystem to generate a POM with a correct <connection> value, referencing the repository from which the incremental was built (which could be a fork). @jglick, what do you think?

@basil
Copy link
Member Author

basil commented Aug 1, 2019

I sketched out a possible solution to the second half of this problem in JENKINS-58716 (comment).

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Looks like this wasn't just a small matter of programming after all!

The "small matter of programming" idiom exists specially for these cases

@jglick
Copy link
Member

jglick commented Sep 10, 2019

Last I remember, this was still a WiP pending integration with CHANGE_FORK, right?

@basil
Copy link
Member Author

basil commented Sep 11, 2019

Last I remember, this was still a WiP pending integration with CHANGE_FORK, right?

No, I don't view this as a WiP. This PR is necessary but not sufficient to fix JENKINS-58716. However, I believe it is ready to merge as-is today. From my previous comment:

Based on this evaluation, I think the change in this PR is makes the situation no worse for non-incremental builds and is necessary but not sufficient for fixing JENKINS-58716 for incremental builds. Therefore I think we should go ahead with this PR.

Since writing that, I found another use case where this PR would have an immediate benefit as-is. When trying to add Swarm to the BOM's managed, set I got this error:

Caused by: java.lang.RuntimeException: The git-checkout command failed. || Cloning into '/home/basil/work/third-party/jenkinsci/bom/target/local-test/pct-work/swarm'...
From git://github.com/jenkinsci/swarm-plugin
 * branch            HEAD       -> FETCH_HEAD
error: pathspec 'swarm-3.17' did not match any file(s) known to git

        at org.jenkins.tools.test.PluginCompatTester.cloneFromSCM(PluginCompatTester.java:559)
        at org.jenkins.tools.test.PluginCompatTester.testPluginAgainst(PluginCompatTester.java:462)
        ... 2 more

The cause of this issue is that Swarm uses tags of the form swarm-plugin-3.17 rather than swarm-3.17. This information is present in Swarm's POM, though. Merging this PR should fix this problem. Therefore this PR has independent value even though the additional CHANGE_FORK work is still pending.

@oleg-nenashev
Copy link
Member

Merge conflict after #185

@basil
Copy link
Member Author

basil commented Sep 11, 2019

Merge conflict after #185

I resolved the merge conflict. I also added links to two test runs that demonstrate the code is correctly able to parse SCM tags from the POM and check out the correct tag. The point is that scmTag is a more reliable way of determining what to check out than trying to manually construct a tag name.

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

LGTM

@jglick
Copy link
Member

jglick commented Sep 11, 2019

This PR is necessary but not sufficient to fix JENKINS-58716.

Have you been able to confirm yet that it works for that purpose—that if given a POM which contains a commit hash rather than a tag as the scmTag, the PCT checkout will succeed?

@basil
Copy link
Member Author

basil commented Sep 11, 2019

Have you been able to confirm yet that it works for that purpose—that if given a POM which contains a commit hash rather than a tag as the scmTag, the PCT checkout will succeed?

Yes, I did confirm that, as I wrote in my previous comment:

I reproduced the error calling cloneFromSCM in my IDE and found that changing the value of <connection> from scm:git:git://github.com/jenkinsci/git-server-plugin.git to scm:git:git://github.com/basil/git-server-plugin.git fixed the problem.

@basil
Copy link
Member Author

basil commented Sep 11, 2019

Perhaps you could take a look at my latest revision again. I made two small improvements:

  • Added log statements to make it clear whether the tag was being taken from the POM or inferred.
  • Made the behavior of AbstractMultiParentHook consistent with that of PluginCompatTester. Now both of them attempt to use the POM's SCM tag before trying to infer the tag.

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Would be nice to avoid code duplication, but the rest LGTM

@basil
Copy link
Member Author

basil commented Sep 12, 2019

Would be nice to avoid code duplication, but the rest LGTM

Agreed. I only just started working with this codebase, but I already see many possible areas for improvement, this being one of them. Maybe as I get time I'll attempt some further cleanup, once I get more familiarity with the codebase and can gain more confidence that I won't be breaking things.

@oleg-nenashev
Copy link
Member

oleg-nenashev commented Sep 12, 2019 via email

@basil
Copy link
Member Author

basil commented Sep 16, 2019

Test failure doesn't appear related to this change:

[2019-09-16T08:17:32.286Z] Exception in thread "main" java.io.IOException: Unable to open file /home/jenkins/workspace/ries_plugin-compat-tester_PR-181/out/pct-report.xsl for writing.
[2019-09-16T08:17:32.286Z] 	at org.codehaus.plexus.util.FileUtils.checkCanWrite(FileUtils.java:1240)
[2019-09-16T08:17:32.286Z] 	at org.codehaus.plexus.util.FileUtils.copyStreamToFile(FileUtils.java:1212)
[2019-09-16T08:17:32.286Z] 	at org.jenkins.tools.test.PluginCompatTester.testPlugins(PluginCompatTester.java:161)
[2019-09-16T08:17:32.286Z] 	at org.jenkins.tools.test.PluginCompatTesterCli.main(PluginCompatTesterCli.java:163)
script returned exit code 1

Closing and re-opening to trigger a new build.

@basil basil closed this Sep 16, 2019
@basil basil reopened this Sep 16, 2019
@basil
Copy link
Member Author

basil commented Sep 18, 2019

I think we should be good to move forward with this. Let me know if there's any other changes you want me to make.

@oleg-nenashev oleg-nenashev changed the title [JENKINS-58716] Failure to check out specified tag for incremental version [JENKINS-58716] Fix check out of incremental versions Sep 18, 2019
@oleg-nenashev oleg-nenashev changed the title [JENKINS-58716] Fix check out of incremental versions [JENKINS-58716] Fix check out of plugins with Incremental versions Sep 18, 2019
@oleg-nenashev oleg-nenashev changed the title [JENKINS-58716] Fix check out of plugins with Incremental versions [JENKINS-58716] Support checking out plugins with Incremental versions Sep 18, 2019
@oleg-nenashev
Copy link
Member

After some consideration I will merge it as an enhancement, not as a bugfix. PCT has never really worked with Incrementals, but with this patch we are getting closer to it.

@oleg-nenashev oleg-nenashev merged commit 0f170ab into jenkinsci:master Sep 18, 2019
@oleg-nenashev
Copy link
Member

@basil would you like to have a new release of PCT? Or are you fine with taking it from the branch?

@basil
Copy link
Member Author

basil commented Sep 20, 2019

@basil would you like to have a new release of PCT? Or are you fine with taking it from the branch?

Thanks for checking. I think I'm fine without a release for now. There are a few other fixes I want to make in PCT so I think it makes sense to bunch them together before shipping a release.

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