Skip to content
Permalink
Browse files

[JENKINS-9067] adding poll only on master option

  • Loading branch information...
Rob Petti
Rob Petti committed Mar 23, 2011
1 parent 3c80ed4 commit 23f722ed51b3d42ec90844f34026707b2db253c2
@@ -211,6 +211,11 @@
private boolean useViewMaskForPolling = true;
private boolean useViewMaskForSyncing = false;

/**
* Sync only on master option.
*/
private boolean pollOnlyOnMaster = false;

/**
* charset options
*/
@@ -243,6 +248,7 @@ public PerforceSCM(
boolean wipeRepoBeforeBuild,
boolean dontUpdateClient,
boolean exposeP4Passwd,
boolean pollOnlyOnMaster,
String slaveClientNameFormat,
int firstChange,
PerforceRepositoryBrowser browser,
@@ -255,6 +261,7 @@ public PerforceSCM(
this.exposeP4Passwd = exposeP4Passwd;
this.p4Client = p4Client;
this.p4Port = p4Port;
this.pollOnlyOnMaster = pollOnlyOnMaster;
this.projectOptions = (projectOptions != null)
? projectOptions
: "noallwrite clobber nocompress unlocked nomodtime rmdir";
@@ -809,13 +816,22 @@ public boolean pollChanges(AbstractProject project, Launcher launcher,
Depot depot;

try {
//try to get an active node that the project is configured to use
Node buildNode = project.getLastBuiltOn();
if (!isNodeOnline(buildNode)){
if (pollOnlyOnMaster){
buildNode = null;
}
if (buildNode == null){
buildNode = getOnlineConfiguredNode(project);
} else {
//try to get an active node that the project is configured to use
buildNode = project.getLastBuiltOn();

if (!isNodeOnline(buildNode)){
buildNode = null;
}
if (buildNode == null && !pollOnlyOnMaster){
buildNode = getOnlineConfiguredNode(project);
}
if (pollOnlyOnMaster){
buildNode = null;
}
}
if (buildNode == null){
depot = getDepot(launcher,workspace,project);
@@ -2105,6 +2121,14 @@ public void setExcludedFiles(String files) {
excludedFiles = files;
}

public boolean isPollOnlyOnMaster() {
return pollOnlyOnMaster;
}

public void setPollOnlyOnMaster(boolean pollOnlyOnMaster) {
this.pollOnlyOnMaster = pollOnlyOnMaster;
}

public List<String> getAllLineEndChoices(){
List<String> allChoices = ((PerforceSCMDescriptor)this.getDescriptor()).getAllLineEndChoices();
ArrayList<String> choices = new ArrayList<String>();
@@ -73,6 +73,10 @@
<f:checkbox field="disableSyncOnly" value="False"/>
</f:entry>

<f:entry title="Poll Only on Master" help="/plugin/perforce/help/pollOnlyOnMaster.html">
<f:checkbox field="pollOnlyOnMaster" value="False"/>
</f:entry>

<f:entry title="First Changelist to Track" help="/plugin/perforce/help/firstChange.html">
<f:textbox field="firstChange"
checkUrl="'${rootURL}/scm/PerforceSCM/checkChangeList?port='+escape(document.forms[1].p4Port.value)+'&amp;exe='+escape(document.forms[1].p4Exe.value)+'&amp;user='+escape(document.forms[1].p4User.value)+'&amp;pass='+escape(document.forms[1].p4Passwd.value)+'&amp;change='+escape(this.value)"/>
@@ -0,0 +1,7 @@
<div>
<p>
<b>Poll Only on Master</b>: enabling this setting will cause the perforce plugin to only ever poll using the master.
By default, the plugin will attempt to use any active nodes that the job is configured to use. In the case of volatile, on-demand environments,
greater stability may be acheived by enabling this option. Only enable this option if the perforce configuration in the job is known to work on the master.
</p>
</div>
@@ -22,7 +22,7 @@ public void testConfigRoundtrip() throws Exception {
PerforceSCM scm = new PerforceSCM(
"user", "pass", "client", "port", "path", "", "exe", "sysRoot",
"sysDrive", "label", "counter", "shared", "charset", "charset2", false, true, true, true, false,
false, true, false, false, false, "${basename}", 0, browser, "exclude_user", "exclude_file");
false, true, false, false, false, false, "${basename}", 0, browser, "exclude_user", "exclude_file");
project.setScm(scm);

// config roundtrip
@@ -43,7 +43,7 @@ public void testConfigPasswordEnctyptionAndDecription() throws Exception {
PerforceSCM scm = new PerforceSCM(
"user", password, "client", "port", "path", "", "exe", "sysRoot",
"sysDrive", "label", "counter", "shared", "charset", "charset2", false, true, true, true, false,
false, true, false, false, false, "${basename}", 0, browser, "exclude_user", "exclude_file");
false, true, false, false, false, false, "${basename}", 0, browser, "exclude_user", "exclude_file");
project.setScm(scm);

// config roundtrip
@@ -67,7 +67,7 @@ public void testDepotContainsUnencryptedPassword() throws Exception {
PerforceSCM scm = new PerforceSCM(
"user", password, "client", "port", "path", "", "exe", "sysRoot",
"sysDrive", "label", "counter", "shared", "charset", "charset2", false, true, true, true, false,
false, true, false, false, false, "${basename}", 0, browser, "exclude_user", "exclude_file");
false, true, false, false, false, false, "${basename}", 0, browser, "exclude_user", "exclude_file");

project.setScm(scm);

@@ -81,7 +81,7 @@ public void testConfigSaveReloadAndSaveDoesNotDoubleEncryptThePassword() throws
PerforceSCM scm = new PerforceSCM(
"user", password, "client", "port", "path", "", "exe", "sysRoot",
"sysDrive", "label", "counter", "shared", "charset", "charset2", false, true, true, true, false,
false, true, false, false, false, "${basename}", 0, browser, "exclude_user", "exclude_file");
false, true, false, false, false, false, "${basename}", 0, browser, "exclude_user", "exclude_file");
project.setScm(scm);

// config roundtrip

0 comments on commit 23f722e

Please sign in to comment.
You can’t perform that action at this time.