Skip to content

Commit

Permalink
[JENKINS-13646] added 'owner' field to advanced options
Browse files Browse the repository at this point in the history
  • Loading branch information
rpetti committed May 1, 2012
1 parent 2d0fb17 commit 7eab18d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/main/java/hudson/plugins/perforce/PerforceSCM.java
Expand Up @@ -76,6 +76,7 @@ public class PerforceSCM extends SCM {
String p4Label;
String p4Counter;
String p4Stream;
String clientOwner;

/**
* Transient so that old XML data will be read but not saved.
Expand Down Expand Up @@ -268,6 +269,7 @@ public PerforceSCM(
String lineEndValue,
String p4Charset,
String p4CommandCharset,
String clientOwner,
boolean updateCounterValue,
boolean forceSync,
boolean dontUpdateServer,
Expand Down Expand Up @@ -314,6 +316,8 @@ public PerforceSCM(
this.updateCounterValue = updateCounterValue;

this.projectPath = Util.fixEmptyAndTrim(projectPath);

this.clientOwner = Util.fixEmptyAndTrim(clientOwner);

if (p4SysRoot != null && p4SysRoot.length() != 0)
this.p4SysRoot = Util.fixEmptyAndTrim(p4SysRoot);
Expand Down Expand Up @@ -536,6 +540,10 @@ public Object readResolve() {
if(excludedFilesCaseSensitivity == null) {
excludedFilesCaseSensitivity = Boolean.TRUE;
}

if(clientOwner == null) {
clientOwner = "";
}

if(configVersion == null) {
configVersion = 0L;
Expand Down Expand Up @@ -1434,6 +1442,10 @@ else if (dontRenameClient) {
if (lineEndValue != null && getAllLineEndChoices().contains(lineEndValue)){
p4workspace.setLineEnd(lineEndValue);
}

if (clientOwner != null && !clientOwner.trim().isEmpty()){
p4workspace.setOwner(clientOwner);
}

// Ensure that the root is appropriate (it might be wrong if the user
// created it, or if we previously built on another node).
Expand Down
Expand Up @@ -95,6 +95,11 @@
<f:textbox field="projectOptions" default="noallwrite clobber nocompress unlocked nomodtime rmdir"
value="${instance.projectOptions}" />
</f:entry>

<f:entry title="Client Owner" help="/plugin/perforce/help/clientOwner.html">
<f:textbox field="clientOwner" default=""
value="${instance.clientOwner}" />
</f:entry>

<f:entry title="One Time Force Sync" help="/plugin/perforce/help/forceSync.html">
<f:checkbox field="forceSync" value="True" id="forceSync" onchange="this.form.elements['dontUpdateServer'].changed();"/>
Expand Down
5 changes: 5 additions & 0 deletions src/main/webapp/help/clientOwner.html
@@ -0,0 +1,5 @@
<div>
<p>
<b>Client Owner</b>: This is the username to set the perforce client's owner to. If left blank, your Perforce server will normally choose a default for you, which is typically the username used with the plugin.
</p>
</div>
10 changes: 5 additions & 5 deletions src/test/java/hudson/plugins/perforce/PerforceSCMTest.java
Expand Up @@ -26,7 +26,7 @@ public void testConfigRoundtrip() throws Exception {
P4Web browser = new P4Web(new URL("http://localhost/"));
PerforceSCM scm = new PerforceSCM(
"user", "pass", "client", "port", "", "exe", "sysRoot",
"sysDrive", "label", "counter", "shared", "charset", "charset2", false, true, true, true, true, true, false,
"sysDrive", "label", "counter", "shared", "charset", "charset2", "user", false, true, true, true, true, true, false,
false, false, true, false, false, false, false, "${basename}", 0, -1, browser, "exclude_user", "exclude_file", true);
scm.setProjectPath("path");
project.setScm(scm);
Expand All @@ -47,7 +47,7 @@ public void testConfigRoundtripWithStream() throws Exception {
P4Web browser = new P4Web(new URL("http://localhost/"));
PerforceSCM scm = new PerforceSCM(
"user", "pass", "client", "port", "", "exe", "sysRoot",
"sysDrive", "label", "counter", "shared", "charset", "charset2", false, true, true, true, true, true, false,
"sysDrive", "label", "counter", "shared", "charset", "charset2", "user", false, true, true, true, true, true, false,
false, false, true, false, false, false, false, "${basename}", 0, -1, browser, "exclude_user", "exclude_file", true);
scm.setP4Stream("stream");
scm.setUseStreamDepot(true);
Expand All @@ -74,7 +74,7 @@ public void testConfigPasswordEnctyptionAndDecription() throws Exception {
String password = "pass";
PerforceSCM scm = new PerforceSCM(
"user", password, "client", "port", "", "test_installation", "sysRoot",
"sysDrive", "label", "counter", "shared", "charset", "charset2", false, true, true, true, true, true, false,
"sysDrive", "label", "counter", "shared", "charset", "charset2", "user", false, true, true, true, true, true, false,
false, false, true, false, false, false, false, "${basename}", 0, -1, browser, "exclude_user", "exclude_file", true);
scm.setProjectPath("path");
project.setScm(scm);
Expand Down Expand Up @@ -103,7 +103,7 @@ public void testDepotContainsUnencryptedPassword() throws Exception {
String password = "pass";
PerforceSCM scm = new PerforceSCM(
"user", password, "client", "port", "", "test_installation", "sysRoot",
"sysDrive", "label", "counter", "shared", "charset", "charset2", false, true, true, true, true, true, false,
"sysDrive", "label", "counter", "shared", "charset", "charset2", "user", false, true, true, true, true, true, false,
false, false, true, false, false, false, false, "${basename}", 0, -1, browser, "exclude_user", "exclude_file", true);
scm.setProjectPath("path");
project.setScm(scm);
Expand All @@ -121,7 +121,7 @@ public void testConfigSaveReloadAndSaveDoesNotDoubleEncryptThePassword() throws
String password = "pass";
PerforceSCM scm = new PerforceSCM(
"user", password, "client", "port", "", "test_installation", "sysRoot",
"sysDrive", "label", "counter", "shared", "charset", "charset2", false, true, true, true, true, true, false,
"sysDrive", "label", "counter", "shared", "charset", "charset2", "user", false, true, true, true, true, true, false,
false, false, true, false, false, false, false, "${basename}", 0, -1, browser, "exclude_user", "exclude_file", true);
scm.setProjectPath("path");
project.setScm(scm);
Expand Down

0 comments on commit 7eab18d

Please sign in to comment.