Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-47073: Use getName instead of getDisplayName to build urls
  • Loading branch information
imeredith committed Oct 3, 2017
1 parent 6b854bc commit 66008c2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Expand Up @@ -69,12 +69,12 @@ public String getRunURL(Run<?, ?> run) {
WorkflowJob job = ((WorkflowRun) run).getParent();
if (job.getParent() instanceof MultiBranchProject) {
String jobURL = getJobURL(organization, ((MultiBranchProject) job.getParent()));
return String.format("%sdetail/%s/%d/", jobURL, Util.rawEncode(job.getDisplayName()), run.getNumber());
return String.format("%sdetail/%s/%d/", jobURL, job.getName(), run.getNumber());
}
}
Job job = run.getParent();
String jobURL = getJobURL(organization, job);
return String.format("%sdetail/%s/%d/", jobURL, Util.rawEncode(job.getDisplayName()), run.getNumber());
return String.format("%sdetail/%s/%d/", jobURL, Util.rawEncode(job.getName()), run.getNumber());
}

@Override
Expand Down
Expand Up @@ -100,19 +100,14 @@ public void testProjectURL() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("abc");
String url = getPath(displayURL.getJobURL(p));
Assert.assertEquals("/jenkins/blue/organizations/jenkins/abc/", url);
}

@Test
public void testProjectURL_CustomOrganization() throws Exception {
FreeStyleProject p = orgFolder.createProject(FreeStyleProject.class, "abc");
String url = getPath(displayURL.getJobURL(p));
Assert.assertEquals("/jenkins/blue/organizations/TestOrg/abc/", url);
}

@Test
public void testProjectInFolder() throws Exception {
MockFolder folder = j.createFolder("test");
Project p = folder.createProject(FreeStyleProject.class, "abc");
p.setDisplayName("custom name");
String url = getPath(displayURL.getJobURL(p));
Assert.assertEquals("/jenkins/blue/organizations/jenkins/test%2Fabc/", url);

Expand Down Expand Up @@ -162,6 +157,26 @@ public void testMultibranchUrls() throws Exception {
Assert.assertEquals("/jenkins/blue/organizations/jenkins/folder%2Ftest/detail/feature%2Ftest-1/1/changes", url);
}

@Test
public void testMultibranchUrlsWithDisplayNameBranches() throws Exception {
repo.checkoutNewBranch("feature/test-1")
.writeJenkinsFile(JenkinsFile.createFile().node().stage("stage1").echo("test").endNode())
.addFile("Jenkinsfile")
.commit("Initial commit to feature/test-1");

MultiBranchTestBuilder mp = MultiBranchTestBuilder.createProjectInFolder(j, "folder", "test", gitSampleRepoRule);

WorkflowJob job = mp.scheduleAndFindBranchProject("feature%2Ftest-1");
job.setDisplayName("Custom Name");
String url = getPath(displayURL.getRunURL(job.getFirstBuild()));

Assert.assertEquals("/jenkins/blue/organizations/jenkins/folder%2Ftest/detail/feature%2Ftest-1/1/", url);

url = getPath(displayURL.getChangesURL(job.getFirstBuild()));
Assert.assertEquals("/jenkins/blue/organizations/jenkins/folder%2Ftest/detail/feature%2Ftest-1/1/changes", url);
}


@Test
public void testMultibranchUrls_CustomOrganization() throws Exception {
repo.checkoutNewBranch("feature/test-1")
Expand Down

0 comments on commit 66008c2

Please sign in to comment.