Skip to content

Commit

Permalink
Jenkins 47073 dont use displayname (#11)
Browse files Browse the repository at this point in the history
* JENKINS-47073: Use getName instead of getDisplayName to build urls

* Add test back

* Rebuild

* Updated jenkinsfile

* build on linux

* jenkinsfile from Blueocean

* fix net

* Git stuff
  • Loading branch information
imeredith committed Oct 17, 2017
1 parent 6b854bc commit dcb76e2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
30 changes: 18 additions & 12 deletions Jenkinsfile
@@ -1,15 +1,21 @@
pipeline {
agent { docker 'maven' }
stages {
stage('build') {
steps {
sh 'mvn clean install'
}
agent { docker 'maven' }
environment {
GIT_COMMITTER_EMAIL = '=me@hatescake.com'
GIT_COMMITTER_NAME = 'Hates'
GIT_AUTHOR_NAME = 'Cakes'
GIT_AUTHOR_EMAIL = 'hates@cake.com'
}
}
post {
always {
junit 'target/**/*.xml'
stages {
stage('build') {
steps {
sh 'mvn clean install'
}
}
}
}
}
post {
always {
junit 'target/**/*.xml'
}
}
}
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,8 +100,8 @@ 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");
Expand All @@ -113,6 +113,7 @@ public void testProjectURL_CustomOrganization() throws Exception {
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 +163,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 dcb76e2

Please sign in to comment.