Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-34051

Polling of Jenkinsfile always finds changes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • p4-plugin
    • None
    • p4-plugin 1.3.9 from master on github and pipeline 1.15.

      When using a Jenkinsfile in perforce with the p4-plugin I polling of the jenkinsfile always succeeds.

      Looking at the code the problem seems to be that p4 cstat always finds a single entry, the last changelist, marked with "need". This means that the poll always finds changes and triggers a build.

      As the Jenkinsfile is only polled on "master" I introduced a workaround which works for us as all other polling is done on slaves:

      diff --git a/src/main/java/org/jenkinsci/plugins/p4/PerforceScm.java b/src/main/java/org/jenkinsci/plugins/p4/PerforceScm.java
      index 1c12e4f..87fc233 100644
      --- a/src/main/java/org/jenkinsci/plugins/p4/PerforceScm.java
      +++ b/src/main/java/org/jenkinsci/plugins/p4/PerforceScm.java
      @@ -197,6 +197,11 @@ public class PerforceScm extends SCM {
                      nodeName = (nodeName.isEmpty()) ? "master" : nodeName;
                      envVars.put("NODE_NAME", envVars.get("NODE_NAME", nodeName));
       
      +                if (nodeName.equals("master")) {
      +                        log.println("P4: Polling disabled on master...");
      +                        return PollingResult.NO_CHANGES;
      +                }
      +
                      Workspace ws = (Workspace) workspace.clone();
                      ws.setExpand(envVars);
      

      With this things are good enough for the moment, but understanding why cstat always returns need on the script file would be good. One thing I noted is that the workspace has no root set, maybe because the format of the script workspace is "workspace@script" which is not a valid root for a workspace in perforce?

            p4paul Paul Allen
            pyssling Nils Carlson
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: