|
40 | 40 | import hudson.model.Result;
|
41 | 41 | import hudson.model.Run;
|
42 | 42 | import hudson.model.TaskListener;
|
43 |
| -import hudson.plugins.git.GitSCM; |
| 43 | +import hudson.plugins.git.ApiTokenPropertyConfiguration; |
44 | 44 | import hudson.plugins.git.BranchSpec;
|
| 45 | +import hudson.plugins.git.GitSCM; |
45 | 46 | import hudson.scm.ChangeLogSet;
|
46 | 47 | import hudson.scm.SCM;
|
47 | 48 | import hudson.slaves.EnvironmentVariablesNodeProperty;
|
|
79 | 80 | import jenkins.scm.impl.subversion.SubversionSCMSource;
|
80 | 81 | import jenkins.scm.impl.subversion.SubversionSampleRepoRule;
|
81 | 82 | import org.apache.commons.io.FileUtils;
|
| 83 | +import org.htmlunit.WebResponse; |
82 | 84 | import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
|
83 | 85 | import org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition;
|
84 | 86 | import org.jenkinsci.plugins.workflow.job.WorkflowJob;
|
@@ -127,6 +129,28 @@ public class SCMSourceRetrieverTest {
|
127 | 129 | @Rule public LoggerRule logging = new LoggerRule().record(SCMBasedRetriever.class, Level.FINE);
|
128 | 130 |
|
129 | 131 | // Repetitive helpers for test cases dealing with @Issue("JENKINS-69731") and others
|
| 132 | + private void sampleRepoNotifyCommit(GitSampleRepoRule sampleRepo) throws Exception { |
| 133 | + try { |
| 134 | + sampleRepo.notifyCommit(r); |
| 135 | + } catch(java.lang.NoSuchMethodError ignored) { |
| 136 | + // Some versions of git-plugin maybe mix up "WebClient" |
| 137 | + // from "JenkinsRule" and from "htmlunit" packages, while |
| 138 | + // using the former implicitly. Maybe something else; says: |
| 139 | + // java.lang.NoSuchMethodError: 'com.gargoylesoftware.htmlunit.Page |
| 140 | + // org.jvnet.hudson.test.JenkinsRule$WebClient.goTo(java.lang.String, java.lang.String)' |
| 141 | + // The catch-code below is an adapted copy of |
| 142 | + // GitSampleRepoRule.notifyCommit() as of git-plugin-5.0.0: |
| 143 | + |
| 144 | + // SKIPPED: protected code: sampleRepo.synchronousPolling(r); |
| 145 | + String notifyCommitToken = ApiTokenPropertyConfiguration.get().generateApiToken("notifyCommit").getString("value"); |
| 146 | + JenkinsRule.WebClient wc = r.createWebClient(); |
| 147 | + WebResponse webResponse = |
| 148 | + wc.goTo("git/notifyCommit?url=" + sampleRepo.bareUrl() + "&token=" + notifyCommitToken, "text/plain").getWebResponse(); |
| 149 | + // SKIPPED logging of the response |
| 150 | + r.waitUntilNoActivity(); |
| 151 | + } |
| 152 | + } |
| 153 | + |
130 | 154 | private void sampleRepo1ContentMaster() throws Exception {
|
131 | 155 | sampleRepo1ContentMaster(null);
|
132 | 156 | }
|
@@ -492,7 +516,7 @@ private void sampleRepo2ContentUniqueMasterFeatureBogus_staticStrings(String sub
|
492 | 516 | // definition of MBP "leaf" jobs, and launch of builds,
|
493 | 517 | // so below we just make sure they complete and analyze
|
494 | 518 | // the outcomes.
|
495 |
| - sampleRepo2.notifyCommit(r); |
| 519 | + sampleRepoNotifyCommit(sampleRepo2); |
496 | 520 | r.waitUntilNoActivity();
|
497 | 521 | System.out.println("Jobs generated by MBP: " + mbp.getItems().toString());
|
498 | 522 |
|
@@ -550,7 +574,7 @@ private void sampleRepo2ContentUniqueMasterFeatureBogus_staticStrings(String sub
|
550 | 574 | // definition of MBP "leaf" jobs, and launch of builds,
|
551 | 575 | // so below we just make sure they complete and analyze
|
552 | 576 | // the outcomes.
|
553 |
| - sampleRepo2.notifyCommit(r); |
| 577 | + sampleRepoNotifyCommit(sampleRepo2); |
554 | 578 | r.waitUntilNoActivity();
|
555 | 579 | System.out.println("Jobs generated by MBP: " + mbp.getItems().toString());
|
556 | 580 |
|
@@ -608,7 +632,7 @@ private void sampleRepo2ContentUniqueMasterFeatureBogus_staticStrings(String sub
|
608 | 632 | // definition of MBP "leaf" jobs, and launch of builds,
|
609 | 633 | // so below we just make sure they complete and analyze
|
610 | 634 | // the outcomes.
|
611 |
| - sampleRepo2.notifyCommit(r); |
| 635 | + sampleRepoNotifyCommit(sampleRepo2); |
612 | 636 | r.waitUntilNoActivity();
|
613 | 637 | System.out.println("Jobs generated by MBP: " + mbp.getItems().toString());
|
614 | 638 |
|
@@ -681,7 +705,7 @@ private void sampleRepo2ContentUniqueMasterFeatureBogus_staticStrings(String sub
|
681 | 705 | mbp.save();
|
682 | 706 | // Rescan to actually define leaf jobs:
|
683 | 707 | mbp.scheduleBuild(0);
|
684 |
| - sampleRepo2.notifyCommit(r); |
| 708 | + sampleRepoNotifyCommit(sampleRepo2); |
685 | 709 | r.waitUntilNoActivity();
|
686 | 710 | System.out.println("All Jenkins items: " + r.jenkins.getItems().toString());
|
687 | 711 | System.out.println("MBP sources: " + mbp.getSourcesList().toString());
|
@@ -770,7 +794,7 @@ private void sampleRepo2ContentUniqueMasterFeatureBogus_staticStrings(String sub
|
770 | 794 | mbp.save();
|
771 | 795 | // Rescan to actually define leaf jobs:
|
772 | 796 | mbp.scheduleBuild(0);
|
773 |
| - sampleRepo2.notifyCommit(r); |
| 797 | + sampleRepoNotifyCommit(sampleRepo2); |
774 | 798 | r.waitUntilNoActivity();
|
775 | 799 | System.out.println("All Jenkins items: " + r.jenkins.getItems().toString());
|
776 | 800 | System.out.println("MBP sources: " + mbp.getSourcesList().toString());
|
@@ -855,7 +879,7 @@ private void sampleRepo2ContentUniqueMasterFeatureBogus_staticStrings(String sub
|
855 | 879 |
|
856 | 880 | WorkflowJob p0 = r.jenkins.createProject(WorkflowJob.class, "p0");
|
857 | 881 | p0.setDefinition(new CpsScmFlowDefinition(gitSCM, "Jenkinsfile"));
|
858 |
| - sampleRepo2.notifyCommit(r); |
| 882 | + sampleRepoNotifyCommit(sampleRepo2); |
859 | 883 | r.waitUntilNoActivity();
|
860 | 884 |
|
861 | 885 | WorkflowRun b0 = r.buildAndAssertSuccess(p0);
|
@@ -896,7 +920,7 @@ private void sampleRepo2ContentUniqueMasterFeatureBogus_staticStrings(String sub
|
896 | 920 |
|
897 | 921 | WorkflowJob p0 = r.jenkins.createProject(WorkflowJob.class, "p0");
|
898 | 922 | p0.setDefinition(new CpsScmFlowDefinition(gitSCM, "Jenkinsfile"));
|
899 |
| - sampleRepo2.notifyCommit(r); |
| 923 | + sampleRepoNotifyCommit(sampleRepo2); |
900 | 924 | r.waitUntilNoActivity();
|
901 | 925 |
|
902 | 926 | WorkflowRun b0 = r.buildAndAssertSuccess(p0);
|
@@ -945,7 +969,7 @@ private void sampleRepo2ContentUniqueMasterFeatureBogus_staticStrings(String sub
|
945 | 969 | Collections.singletonList(new BranchSpec("*/feature")),
|
946 | 970 | null, null, Collections.emptyList());
|
947 | 971 |
|
948 |
| - sampleRepo2.notifyCommit(r); |
| 972 | + sampleRepoNotifyCommit(sampleRepo2); |
949 | 973 | r.waitUntilNoActivity();
|
950 | 974 |
|
951 | 975 | // First run a job definition with a fixed library version,
|
@@ -1070,7 +1094,7 @@ private void sampleRepo2ContentUniqueMasterFeatureBogus_staticStrings(String sub
|
1070 | 1094 |
|
1071 | 1095 | WorkflowJob p1 = r.jenkins.createProject(WorkflowJob.class, "p1");
|
1072 | 1096 | p1.setDefinition(new CpsScmFlowDefinition(gitSCM, "Jenkinsfile"));
|
1073 |
| - sampleRepo2.notifyCommit(r); |
| 1097 | + sampleRepoNotifyCommit(sampleRepo2); |
1074 | 1098 | r.waitUntilNoActivity();
|
1075 | 1099 | p1.scheduleBuild2(0);
|
1076 | 1100 | r.waitUntilNoActivity();
|
@@ -1131,7 +1155,7 @@ private void sampleRepo2ContentUniqueMasterFeatureBogus_staticStrings(String sub
|
1131 | 1155 | csfd.setLightweight(true);
|
1132 | 1156 | WorkflowJob p0 = r.jenkins.createProject(WorkflowJob.class, "p0");
|
1133 | 1157 | p0.setDefinition(csfd);
|
1134 |
| - sampleRepo2.notifyCommit(r); |
| 1158 | + sampleRepoNotifyCommit(sampleRepo2); |
1135 | 1159 | r.waitUntilNoActivity();
|
1136 | 1160 |
|
1137 | 1161 | WorkflowRun b0 = r.buildAndAssertSuccess(p0);
|
|
0 commit comments