提交 68d4d22f 编写于 作者: K Kohsuke Kawaguchi

[JENKINS-8446] it's better to let those directories setting be a part of...

[JENKINS-8446] it's better to let those directories setting be a part of JENKINS_HOME rather than being independent configuration properties, since they aren't orthogonal.
上级 7fdb8a82
......@@ -55,6 +55,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=rfe>
Allow build directories and workspace directories in $JENKINS_HOME to be placed elsewhere.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-8446">issue 8446</a>)
<li class=rfe>
Mac installer update: set file permissions to be more in line with Mac conventions.
(<a href="https://github.com/jenkinsci/jenkins/pull/188">pull request 188</a>)
......
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Martin Eigenbrodt, Matthew R. Harrah, Red Hat, Inc., Stephen Connolly, Tom Huybrechts
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Martin Eigenbrodt, Matthew R. Harrah, Red Hat, Inc., Stephen Connolly, Tom Huybrechts, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -23,19 +23,15 @@
*/
package hudson.model;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import hudson.EnvVars;
import hudson.Extension;
import hudson.ExtensionPoint;
import hudson.PermalinkList;
import hudson.Extension;
import hudson.cli.declarative.CLIResolver;
import hudson.model.Descriptor.FormException;
import hudson.model.PermalinkProjectAction.Permalink;
import hudson.model.Fingerprint.RangeSet;
import hudson.model.Fingerprint.Range;
import hudson.model.Fingerprint.RangeSet;
import hudson.model.PermalinkProjectAction.Permalink;
import hudson.search.QuickSilver;
import hudson.search.SearchIndex;
import hudson.search.SearchIndexBuilder;
......@@ -49,40 +45,18 @@ import hudson.util.ColorPalette;
import hudson.util.CopyOnWriteList;
import hudson.util.DataSetBuilder;
import hudson.util.DescribableList;
import hudson.util.Graph;
import hudson.util.IOException2;
import hudson.util.RunList;
import hudson.util.ShiftedCategoryAxis;
import hudson.util.StackedAreaRenderer2;
import hudson.util.TextFile;
import hudson.util.Graph;
import hudson.widgets.HistoryWidget;
import hudson.widgets.Widget;
import hudson.widgets.HistoryWidget.Adapter;
import java.awt.Color;
import java.awt.Paint;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.io.PrintWriter;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.LinkedList;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import hudson.widgets.Widget;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
......@@ -94,12 +68,29 @@ import org.jfree.chart.renderer.category.StackedAreaRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.ui.RectangleInsets;
import org.jvnet.localizer.Localizable;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.stapler.StaplerOverridable;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import javax.servlet.ServletException;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import static javax.servlet.http.HttpServletResponse.*;
/**
* A job is an runnable entity under the monitoring of Hudson.
......@@ -639,32 +630,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
* @see RunMap
*/
protected File getBuildDir() {
// check JNDI for the home directory first
try {
InitialContext iniCtxt = new InitialContext();
Context env = (Context) iniCtxt.lookup("java:comp/env");
String value = (String) env.lookup("JENKINS_BUILDS");
if(value!=null && value.trim().length()>0)
return new File(value.trim());
// look at one more place. See issue #1314
value = (String) iniCtxt.lookup("JENKINS_BUILDS");
if(value!=null && value.trim().length()>0)
return new File(value.trim() + "/" + getSearchName());
} catch (NamingException e) {
// ignore
}
// finally check the system property
String sysProp = System.getProperty("JENKINS_BUILDS");
if(sysProp!=null)
return new File(sysProp.trim() + "/" + getSearchName());
// look at the env var next
String env = EnvVars.masterEnvVars.get("JENKINS_BUILDS");
if(env!=null)
return new File(env.trim() + "/" + getSearchName()).getAbsoluteFile();
return new File(getRootDir(), "builds");
return Jenkins.getInstance().getBuildDirFor(this);
}
/**
......
......@@ -26,11 +26,11 @@
package jenkins.model;
import antlr.ANTLRException;
import com.google.common.collect.ImmutableMap;
import com.thoughtworks.xstream.XStream;
import hudson.BulkChange;
import hudson.DNSMultiCast;
import hudson.DescriptorExtensionList;
import hudson.EnvVars;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
......@@ -176,9 +176,6 @@ import org.kohsuke.stapler.jelly.JellyRequestDispatcher;
import org.xml.sax.InputSource;
import javax.crypto.SecretKey;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
......@@ -310,9 +307,20 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
private volatile SecurityRealm securityRealm = SecurityRealm.NO_AUTHENTICATION;
/**
* Root directory for the workspaces.
* Root directory for the workspaces. This value will be variable-expanded against
* job name and JENKINS_HOME.
*
* @see #getWorkspaceFor(TopLevelItem)
*/
private String workspaceDir = "${ITEM_ROOTDIR}/"+WORKSPACE_DIRNAME;
/**
* Root directory for the workspaces. This value will be variable-expanded against
* job name and JENKINS_HOME.
*
* @see #getBuildDirFor(Job)
*/
private String configuredWorkspaceRoot = null;
private String buildsDir = "${ITEM_ROOTDIR}/builds";
/**
* Message displayed in the top page.
......@@ -1696,52 +1704,27 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
return root;
}
private String getConfiguredWorkspaceRoot() {
if (configuredWorkspaceRoot == null) {
try {
InitialContext iniCtxt = new InitialContext();
Context env = (Context) iniCtxt.lookup("java:comp/env");
String value = (String) env.lookup("JENKINS_WORKSPACES");
if(value!=null && value.trim().length()>0) {
configuredWorkspaceRoot = value.trim();
return configuredWorkspaceRoot;
}
// look at one more place. See issue #1314
value = (String) iniCtxt.lookup("JENKINS_WORKSPACES");
if(value!=null && value.trim().length()>0) {
configuredWorkspaceRoot = value.trim();
return configuredWorkspaceRoot;
}
} catch (NamingException e) {
// ignore
}
public FilePath getWorkspaceFor(TopLevelItem item) {
return new FilePath(expandVariablesForDirectory(workspaceDir, item));
}
// finally check the system property
String sysProp = System.getProperty("JENKINS_WORKSPACES");
if(sysProp!=null) {
configuredWorkspaceRoot = sysProp.trim();
return configuredWorkspaceRoot;
}
// look at the env var next
String env = EnvVars.masterEnvVars.get("JENKINS_WORKSPACES");
if(env!=null) {
configuredWorkspaceRoot = env.trim();
return configuredWorkspaceRoot;
}
//not set
configuredWorkspaceRoot = "";
}
return configuredWorkspaceRoot;
public File getBuildDirFor(Job job) {
return expandVariablesForDirectory(buildsDir, job);
}
public FilePath getWorkspaceFor(TopLevelItem item) {
if(getConfiguredWorkspaceRoot().equals("")) {
return new FilePath(new File(item.getRootDir(), WORKSPACE_DIRNAME));
} else {
return new FilePath(new File(getConfiguredWorkspaceRoot() + "/" + item.getName(), WORKSPACE_DIRNAME));
}
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())));
}
public String getRawWorkspaceDir() {
return workspaceDir;
}
public String getRawBuildsDir() {
return buildsDir;
}
public FilePath getRootPath() {
......@@ -2379,6 +2362,9 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
JSONObject json = req.getSubmittedForm();
workspaceDir = json.getString("rawWorkspaceDir");
buildsDir = json.getString("rawBuildsDir");
// keep using 'useSecurity' field as the main configuration setting
// until we get the new security implementation working
// useSecurity = null;
......
# The MIT License
#
# Copyright (c) 2004-2009, Sun Microsystems, Inc., Seiji Sogabe, Simon Wiest
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
Are\ you\ sure\ about\ restarting\ Jenkins?\ Jenkins\ will\ restart\ once\ all\ running\ jobs\ are\ finished.=\
Möchten Sie Jenkins wirklich neu starten? Jenkins wird neu starten, \
sobald alle laufenden Jobs abgeschlossen wurden.
Yes=Ja
# The MIT License
#
# Copyright (c) 2004-2009, Sun Microsystems, Inc., Seiji Sogabe, Simon Wiest
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
Are\ you\ sure\ about\ restarting\ Jenkins?\ Jenkins\ will\ restart\ once\ all\ running\ jobs\ are\ finished.=\
M�chten Sie Jenkins wirklich neu starten? Jenkins wird neu starten, \
sobald alle laufenden Jobs abgeschlossen wurden.
Yes=Ja
# The MIT License
#
# Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Seiji Sogabe, Simon Wiest
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
Jenkins\ Login=Jenkins Anmeldung
Access\ Denied=Zugriff verweigert
User=Benutzer
Password=Kennwort
login=Anmelden
# The MIT License
#
# Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Seiji Sogabe, Simon Wiest
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
Jenkins\ Login=Jenkins Anmeldung
Access\ Denied=Zugriff verweigert
User=Benutzer
Password=Kennwort
login=Anmelden
......@@ -38,6 +38,14 @@ THE SOFTWARE.
<f:entry title="${%Home directory}" help="/help/system-config/homeDirectory.html">
${it.rootDir}
</f:entry>
<f:advanced>
<f:entry field="rawWorkspaceDir" title="${%Workspace Root Directory}">
<f:textbox/>
</f:entry>
<f:entry field="rawBuildsDir" title="${%Build Record Root Directory}">
<f:textbox/>
</f:entry>
</f:advanced>
<f:entry title="${%System Message}" help="/help/system-config/systemMessage.html">
<f:textarea name="system_message" value="${it.systemMessage}"
codemirror-mode="htmlmixed" codemirror-config="mode:'text/html'" />
......
<div>
Specify where Jenkins would store records of the past builds.
This value can include the following variables.
<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".
</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>
\ No newline at end of file
<div>
Specify where Jenkins would store job workspaces on the master node.
This value can include the following variables.
<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".
</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>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册