Skip to content

Commit

Permalink
[JENKINS-10334] adding nodename token for slave client names, with a …
Browse files Browse the repository at this point in the history
…disclaimer
  • Loading branch information
Rob Petti committed Jul 14, 2011
1 parent 4a4830e commit 74e23f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/main/java/hudson/plugins/perforce/PerforceSCM.java
Expand Up @@ -1306,6 +1306,7 @@ private String getEffectiveClientName(String basename, Node buildNode)
String hash = String.valueOf(buildNode.getNodeName().hashCode());

Map<String, String> substitutions = new Hashtable<String,String>();
substitutions.put("nodename", buildNode.getNodeName());
substitutions.put("hostname", host);
substitutions.put("hash", hash);
substitutions.put("basename", basename);
Expand Down Expand Up @@ -2179,16 +2180,6 @@ public String getFirstChange() {
return Integer.valueOf(firstChange).toString();
}

/**
* Get the hostname of the client to use as the node suffix
*/
private static final class GetHostname implements FileCallable<String> {
public String invoke(File f, VirtualChannel channel) throws IOException {
return InetAddress.getLocalHost().getHostName();
}
private static final long serialVersionUID = 1L;
}

/**
* With Perforce the server keeps track of files in the workspace. We never
* want files deleted without the knowledge of the server so we disable the
Expand Down Expand Up @@ -2250,12 +2241,14 @@ public boolean processWorkspaceBeforeDeletion(AbstractProject<?,?> project, File
public boolean isSlaveClientNameStatic() {
Map<String,String> testSub1 = new Hashtable<String,String>();
testSub1.put("hostname", "HOSTNAME1");
testSub1.put("nodename", "NODENAME1");
testSub1.put("hash", "HASH1");
testSub1.put("basename", this.p4Client);
String result1 = substituteParameters(getSlaveClientNameFormat(), testSub1);

Map<String,String> testSub2 = new Hashtable<String,String>();
testSub2.put("hostname", "HOSTNAME2");
testSub2.put("nodename", "NODENAME2");
testSub2.put("hash", "HASH2");
testSub2.put("basename", this.p4Client);
String result2 = substituteParameters(getSlaveClientNameFormat(), testSub2);
Expand Down
2 changes: 2 additions & 0 deletions src/main/webapp/help/clientNameFormat.html
Expand Up @@ -7,10 +7,12 @@
<ul>
<li>${basename} - The client name as configured in the above section</li>
<li>${hostname} - The hostname of the slave</li>
<li>${nodename} - The name of the slave in the CI server. <i>Use this with caution.</i></li>
<li>${hash} - The hash code of the slave name</li>
</ul>
</p>
<p>The recommended default value is "${basename}-${hash}" (without quotes).</p>
<p> When set to the default ${basename} is used, and this also enables polling to occur on the master</p>
<p>This allows polling to occur without the last slave to be online</p>
<p><b>Important Note:</b> Take extra care when using the ${nodename} replacement, as the name may contain characters that Perforce does not support for it's client names.</p>
</div>

0 comments on commit 74e23f1

Please sign in to comment.