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

fix fallback URL #457

Merged
merged 1 commit into from
Feb 13, 2023
Merged

fix fallback URL #457

merged 1 commit into from
Feb 13, 2023

Conversation

jtnord
Copy link
Member

@jtnord jtnord commented Feb 13, 2023

if the fallbackURL succeeded the exception of any prior attempts was still thrown.

fixes #456
amends #404

tested locally with an upcoming security release using the jenkinsci-cert repo. (plugin name, tag and sha redacted)

? java -jar target\plugins-compat-tester-cli.jar -fallbackGitHubOrganization jenkinsci-cert  -workDirectory work -includePlugins theplugin -war C:\Users\jnord\Desktop\SECURITY_com_cloudbees_core_traditional_client-master_2.375.3.6-SNAPSHOT_client-master-2.375.3.6-SNAPSHOT.war
2023-02-13 12:22:48.242+0000 [id=1]     INFO    o.j.t.t.h.MultiParentCompileHook#<init>: Loaded multi-parent compile hook
2023-02-13 12:22:48.403+0000 [id=1]     INFO    o.j.t.test.PluginCompatTester#scanWAR: Scanned contents of C:\Users\jnord\Desktop\SECURITY_com_cloudbees_core_traditional_client-master_2.375.3.6-SNAPSHOT_client-master-2.375.3.6-SNAPSHOT.war with 220 plugins
2023-02-13 12:22:48.483+0000 [id=1]     INFO    o.j.t.test.PluginCompatTester#scanWAR: Scanned contents of C:\Users\jnord\Desktop\SECURITY_com_cloudbees_core_traditional_client-master_2.375.3.6-SNAPSHOT_client-master-2.375.3.6-SNAPSHOT.war with 220 plugins
2023-02-13 12:22:48.489+0000 [id=1]     INFO    o.j.t.test.PluginCompatTester#testPlugins: Starting plugin tests on core coordinates MavenCoordinates[groupId=org.jenkins-ci.main, artifactId=jenkins-war, version=2.375.3-cb-1]
2023-02-13 12:22:48.540+0000 [id=1]     INFO    o.j.t.test.PluginCompatTester#testPluginAgainst:





#############################################
#############################################
##
## Starting to test theplugin the_plugin_version against MavenCoordinates[groupId=org.jenkins-ci.main, artifactId=jenkins-war, version=2.375.3-cb-1]
##
#############################################
#############################################





2023-02-13 12:22:48.577+0000 [id=1]     INFO    o.j.t.test.PluginCompatTester#testPluginAgainst: Created plugin checkout directory C:\workarea\source\github\jenkinsci\plugin-compat-tester\work\theplugin
2023-02-13 12:22:48.577+0000 [id=1]     INFO    o.j.t.test.PluginCompatTester#getScmTag: Using SCM tag thecommitsha from POM
2023-02-13 12:22:48.587+0000 [id=1]     INFO    o.j.t.test.PluginCompatTester#cloneImpl: Checking out from SCM connection URL https://github.com/jenkinsci/theplugin-plugin.git at thecommitsha
2023-02-13 12:22:52.684+0000 [id=1]     INFO    o.j.t.test.PluginCompatTester#cloneImpl: Checking out from SCM connection URL git@github.com:jenkinsci-cert/theplugin-plugin.git at thecommitsha
2023-02-13 12:22:59.047+0000 [id=1]     INFO    o.j.t.t.m.h.PluginCompatTesterHooks#runHooks: Running hook: org.jenkins.tools.test.hook.NodeCleanupBeforeCompileHook
2023-02-13 12:22:59.048+0000 [id=1]     INFO    o.j.t.t.h.NodeCleanupBeforeCompileHook#action: Hook not triggered; continuing
2023-02-13 12:22:59.051+0000 [id=1]     INFO    o.j.t.t.m.ExternalMavenRunner#run: Running mvn.cmd --show-version --batch-mode --errors -ntp --define=failIfNoTests=false clean process-test-classes -Dmaven.javadoc.skip in C:\workarea\source\github\jenkinsci\plugin-compat-tester\work\theplugin >> C:\workarea\source\github\jenkinsci\plugin-compat-tester\work\logs\theplugin\plugintag_against_org.jenkins-ci.main_jenkins-war_2.375.3-cb-1.log
Apache Maven 3.9.0 (9b58d2bad23a66be161c4664ef21ce219c2c8584)
Maven home: c:\java\maven-3.9.0
Java version: 11.0.15, vendor: Eclipse Adoptium, runtime:
  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@jtnord jtnord requested a review from a team as a code owner February 13, 2023 12:29
@jtnord jtnord requested a review from basil February 13, 2023 12:29
// See: https://github.blog/2021-09-01-improving-git-protocol-security-github/
connectionURL = connectionURL.replace("git://", "https://");
}
try {
cloneImpl(connectionURL, scmTag, checkoutDirectory);
break;
return; // checkout was ok
Copy link
Member Author

@jtnord jtnord Feb 13, 2023

Choose a reason for hiding this comment

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

fixes the actual bug where if the first clone failed and a subsequent one passed, the exception would still be thrown as lastException would not be null further down when the loop exited.

@@ -440,12 +440,15 @@ public static void cloneFromScm(
PluginSourcesUnavailableException lastException = null;
for (String connectionURL : connectionURLs) {
if (connectionURL != null) {
if (StringUtils.startsWith(connectionURL, "scm:git:")) {
Copy link
Member Author

@jtnord jtnord Feb 13, 2023

Choose a reason for hiding this comment

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

code was moved up here so that cloneImpl only has to deal with real git URLs, making the logging more user friendly

@jtnord jtnord marked this pull request as draft February 13, 2023 12:47
@jtnord jtnord changed the title we can not fetch specific commits fix fallback URL Feb 13, 2023
This also tidies up the cloneImpl so that it is only expcted to work with
valid Git URLs which makes the logging and commands run cleaer
* @param connectionURL The connection URL, in a format such as
* scm:git:https://github.com/jenkinsci/mailer-plugin.git or
* https://github.com/jenkinsci/mailer-plugin.git
* @param gitURL The git native URL, see the <a
Copy link
Member Author

Choose a reason for hiding this comment

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

makes the logging easier to follow if it spits out the URL that is actually going to be used for the git fetch

@jtnord jtnord marked this pull request as ready for review February 13, 2023 13:29
Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

Whoops, sorry about that! Thanks for the quick fix.

@basil basil merged commit 6da964d into master Feb 13, 2023
@basil basil deleted the fix-fallback-url branch February 13, 2023 17:02
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.

fallbackSCM no longer honoured agter '404
2 participants