|
26 | 26 |
|
27 | 27 | import com.cloudbees.hudson.plugins.folder.computed.FolderComputation; |
28 | 28 | import edu.umd.cs.findbugs.annotations.NonNull; |
| 29 | +import hudson.model.AbstractItem; |
29 | 30 | import hudson.model.DescriptorVisibilityFilter; |
30 | 31 | import hudson.model.Item; |
31 | 32 | import hudson.model.Queue; |
|
53 | 54 | import jenkins.plugins.git.GitSCMSource; |
54 | 55 | import jenkins.plugins.git.GitBranchSCMHead; |
55 | 56 | import jenkins.plugins.git.GitSampleRepoRule; |
| 57 | +import jenkins.plugins.git.traits.BranchDiscoveryTrait; |
56 | 58 | import jenkins.scm.api.SCMHead; |
57 | 59 | import jenkins.scm.api.SCMSource; |
58 | 60 | import jenkins.scm.impl.SingleSCMSource; |
| 61 | +import static org.hamcrest.MatcherAssert.assertThat; |
59 | 62 | import static org.hamcrest.Matchers.*; |
60 | 63 | import org.jenkinsci.plugins.workflow.job.WorkflowJob; |
61 | 64 | import org.jenkinsci.plugins.workflow.job.WorkflowRun; |
62 | | -import static org.junit.Assert.*; |
| 65 | +import static org.junit.Assert.assertEquals; |
| 66 | +import static org.junit.Assert.assertFalse; |
| 67 | +import static org.junit.Assert.assertNull; |
| 68 | +import static org.junit.Assert.assertTrue; |
| 69 | +import static org.junit.Assert.fail; |
63 | 70 | import org.junit.ClassRule; |
64 | 71 | import org.junit.Rule; |
65 | 72 | import org.junit.Test; |
@@ -267,4 +274,34 @@ public DescriptorImpl() { |
267 | 274 | r.assertLogContains("branch=feature2", b2); |
268 | 275 | } |
269 | 276 |
|
| 277 | + @Issue("JENKINS-72613") |
| 278 | + @Test public void reloadMangledName() throws Exception { |
| 279 | + r.jenkins.setQuietPeriod(0); |
| 280 | + sampleRepo.init(); |
| 281 | + sampleRepo.write("Jenkinsfile", "echo 'on master'"); |
| 282 | + sampleRepo.git("add", "Jenkinsfile"); |
| 283 | + sampleRepo.git("commit", "--all", "--message=init"); |
| 284 | + for (var branch : List.of("ok-1", "danger_1")) { |
| 285 | + sampleRepo.git("checkout", "-b", branch, "master"); |
| 286 | + sampleRepo.write("Jenkinsfile", "echo 'on " + branch + "'"); |
| 287 | + sampleRepo.git("add", "Jenkinsfile"); |
| 288 | + sampleRepo.git("commit", "--all", "--message=" + branch); |
| 289 | + } |
| 290 | + var mp = r.jenkins.createProject(WorkflowMultiBranchProject.class, "p"); |
| 291 | + var source = new GitSCMSource(sampleRepo.toString()); |
| 292 | + source.setTraits(List.of(new BranchDiscoveryTrait())); |
| 293 | + mp.getSourcesList().add(new BranchSource(source)); |
| 294 | + var ok = scheduleAndFindBranchProject(mp, "ok-1"); |
| 295 | + var danger = findBranchProject(mp, "danger_1"); |
| 296 | + r.waitUntilNoActivity(); |
| 297 | + assertThat(ok.getRootDir().getName(), is("ok-1")); |
| 298 | + assertThat(danger.getRootDir().getName(), is("danger-1.i2g9ue")); |
| 299 | + ok.doReload(); |
| 300 | + assertThat(mp.getItems().stream().map(AbstractItem::getName).toArray(String[]::new), |
| 301 | + arrayContainingInAnyOrder("master", "ok-1", "danger_1")); |
| 302 | + danger.doReload(); |
| 303 | + assertThat(mp.getItems().stream().map(AbstractItem::getName).toArray(String[]::new), |
| 304 | + arrayContainingInAnyOrder("master", "ok-1", "danger_1")); |
| 305 | + } |
| 306 | + |
270 | 307 | } |
0 commit comments