Skip to content

Commit

Permalink
[FIXED JENKINS-12251]
Browse files Browse the repository at this point in the history
Introduced ${ITEM_FULL_NAME} to address the ticket without causing the
backward compatibility problem.
  • Loading branch information
kohsuke committed Feb 16, 2013
1 parent f440a54 commit 61a83bd
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
4 changes: 4 additions & 0 deletions changelog.html
Expand Up @@ -55,6 +55,10 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
${ITEM_FULLNAME} variable was not working for Maven projects on Windows,
so introduced ${ITEM_FULL_NAME} instead.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-12251">issue 12251</a>)
<li class=bug>
Lock contention issue in build history view.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16831">issue 16831</a>)
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/jenkins/model/Jenkins.java
Expand Up @@ -1933,7 +1933,8 @@ private File expandVariablesForDirectory(String base, Item item) {
return new File(Util.replaceMacro(base, ImmutableMap.of(
"JENKINS_HOME", getRootDir().getPath(),
"ITEM_ROOTDIR", item.getRootDir().getPath(),
"ITEM_FULLNAME", item.getFullName())));
"ITEM_FULLNAME", item.getFullName(), // legacy, deprecated
"ITEM_FULL_NAME", item.getFullName().replace(':','$')))); // safe, see JENKINS-12251
}

public String getRawWorkspaceDir() {
Expand Down
Expand Up @@ -5,11 +5,11 @@
<ul>
<li><tt>${JENKINS_HOME}</tt> &mdash; Jenkins home directory
<li><tt>${ITEM_ROOTDIR}</tt> &mdash; Root directory of a job for which the workspace is allocated.
<li><tt>${ITEM_FULLNAME}</tt> &mdash; '/'-separated job name, like "foo/bar".
<li><tt>${ITEM_FULL_NAME}</tt> &mdash; '/'-separated job name, like "foo/bar".
</ul>

<p>
Changing this value allows you to put build records on a bigger but slow disk,
while keeping JENKINS_HOME on highly available backed up drive, for example.
Default value is <tt>${ITEM_ROOTDIR}/builds</tt>.
</div>
</div>
Expand Up @@ -5,7 +5,7 @@
<ul>
<li><tt>${JENKINS_HOME}</tt> &mdash; Jenkinsのホームディレクトリ
<li><tt>${ITEM_ROOTDIR}</tt> &mdash; ワークスペースを配置するジョブのルートディレクトリ
<li><tt>${ITEM_FULLNAME}</tt> &mdash; "foo/bar"のように、'/'区切りのジョブ名
<li><tt>${ITEM_FULL_NAME}</tt> &mdash; "foo/bar"のように、'/'区切りのジョブ名
</ul>

<p>
Expand Down
Expand Up @@ -5,10 +5,10 @@
<ul>
<li><tt>${JENKINS_HOME}</tt> &mdash; Jenkins home directory
<li><tt>${ITEM_ROOTDIR}</tt> &mdash; Root directory of a job for which the workspace is allocated.
<li><tt>${ITEM_FULLNAME}</tt> &mdash; '/'-separated job name, like "foo/bar".
<li><tt>${ITEM_FULL_NAME}</tt> &mdash; '/'-separated job name, like "foo/bar".
</ul>

<p>
Changing this value allows you to put workspaces on SSD, SCSI, or even ram disks.
Default value is <tt>${ITEM_ROOTDIR}/workspace</tt>.
</div>
</div>
Expand Up @@ -5,10 +5,10 @@
<ul>
<li><tt>${JENKINS_HOME}</tt> &mdash; Jenkinsのホームディレクトリ
<li><tt>${ITEM_ROOTDIR}</tt> &mdash; ワークスペースを配置するジョブのルートディレクトリ
<li><tt>${ITEM_FULLNAME}</tt> &mdash; "foo/bar"のように、'/'区切りのジョブ名
<li><tt>${ITEM_FULL_NAME}</tt> &mdash; "foo/bar"のように、'/'区切りのジョブ名
</ul>

<p>
この値を変更することで、ワークスペースをSSD、SCSIあるいはRAMディスク上にワークスペースを配置することができます。
デフォルト値は、<tt>${ITEM_ROOTDIR}/workspace</tt>です。
</div>
</div>
21 changes: 21 additions & 0 deletions test/src/test/java/jenkins/model/JenkinsTest.java
Expand Up @@ -24,6 +24,9 @@
package jenkins.model;

import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import hudson.maven.MavenModuleSet;
import hudson.maven.MavenModuleSetBuild;
import hudson.model.InvisibleAction;
import hudson.model.RootAction;
import hudson.model.UnprotectedRootAction;
Expand All @@ -35,6 +38,7 @@

import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.ExtractResourceSCM;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.TestExtension;
import org.kohsuke.stapler.HttpResponse;
Expand Down Expand Up @@ -174,6 +178,23 @@ public void testDoCheckDisplayNameSameAsJobName() throws Exception {
Assert.assertEquals(FormValidation.Kind.WARNING, v.kind);
}

@Bug(12251)
public void testItemFullNameExpansion() throws Exception {
HtmlForm f = createWebClient().goTo("/configure").getFormByName("config");
f.getInputByName("_.rawBuildsDir").setValueAttribute("${JENKINS_HOME}/test12251_builds/${ITEM_FULL_NAME}");
f.getInputByName("_.rawWorkspaceDir").setValueAttribute("${JENKINS_HOME}/test12251_ws/${ITEM_FULL_NAME}");
submit(f);

// build a dummy project
MavenModuleSet m = createMavenProject();
m.setScm(new ExtractResourceSCM(getClass().getResource("/simple-projects.zip")));
MavenModuleSetBuild b = m.scheduleBuild2(0).get();

// make sure these changes are effective
assertTrue(b.getWorkspace().getRemote().contains("test12251_ws"));
assertTrue(b.getRootDir().toString().contains("test12251_builds"));
}

/**
* Makes sure access to "/foobar" for UnprotectedRootAction gets through.
*/
Expand Down

0 comments on commit 61a83bd

Please sign in to comment.