• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • repo-plugin
    • None

      when using with pipeline job, scm polling is not working, the following is what we got in polling log,

      Started on Jul 15, 2016 4:00:00 PM
      no polling baseline in /home/build/workspace/test on build-agent
      Done. Took 0 ms
      No changes

          [JENKINS-36703] Polling is not working in pipeline job

          Makson Lee added a comment -

          WorkflowJob.java:

              @Override public PollingResult poll(TaskListener listener) {
                  // TODO call SCMPollListener
                  WorkflowRun lastBuild = getLastBuild();
                  if (lastBuild == null) {
                      listener.getLogger().println("no previous build to compare to");
                      // Note that we have no equivalent of AbstractProject.NoSCM because without an initial build we do not know if this project has any SCM at all.
                      return Queue.getInstance().contains(this) ? PollingResult.NO_CHANGES : PollingResult.BUILD_NOW;
                  }
                  WorkflowRun perhapsCompleteBuild = getLastSuccessfulBuild();
                  if (perhapsCompleteBuild == null) {
                      perhapsCompleteBuild = lastBuild;
                  }
                  if (pollingBaselines == null) {
                      pollingBaselines = new ConcurrentHashMap<String,SCMRevisionState>();
                  }
                  PollingResult result = PollingResult.NO_CHANGES;
                  for (WorkflowRun.SCMCheckout co : perhapsCompleteBuild.checkouts(listener)) {
                      if (!co.scm.supportsPolling()) {
                          listener.getLogger().println("polling not supported from " + co.workspace + " on " + co.node);
                          continue;
                      }
                      String key = co.scm.getKey();
                      SCMRevisionState pollingBaseline = pollingBaselines.get(key);
                      if (pollingBaseline == null) {
                          pollingBaseline = co.pollingBaseline; // after a restart, transient cache will be empty
                      }
                      if (pollingBaseline == null) {
          listener.getLogger().println("no polling baseline in " + co.workspace + " on " + co.node);
          

          Makson Lee added a comment - WorkflowJob.java: @Override public PollingResult poll(TaskListener listener) { // TODO call SCMPollListener WorkflowRun lastBuild = getLastBuild(); if (lastBuild == null ) { listener.getLogger().println( "no previous build to compare to" ); // Note that we have no equivalent of AbstractProject.NoSCM because without an initial build we do not know if this project has any SCM at all. return Queue.getInstance().contains( this ) ? PollingResult.NO_CHANGES : PollingResult.BUILD_NOW; } WorkflowRun perhapsCompleteBuild = getLastSuccessfulBuild(); if (perhapsCompleteBuild == null ) { perhapsCompleteBuild = lastBuild; } if (pollingBaselines == null ) { pollingBaselines = new ConcurrentHashMap< String ,SCMRevisionState>(); } PollingResult result = PollingResult.NO_CHANGES; for (WorkflowRun.SCMCheckout co : perhapsCompleteBuild.checkouts(listener)) { if (!co.scm.supportsPolling()) { listener.getLogger().println( "polling not supported from " + co.workspace + " on " + co.node); continue ; } String key = co.scm.getKey(); SCMRevisionState pollingBaseline = pollingBaselines.get(key); if (pollingBaseline == null ) { pollingBaseline = co.pollingBaseline; // after a restart, transient cache will be empty } if (pollingBaseline == null ) { listener.getLogger().println( "no polling baseline in " + co.workspace + " on " + co.node);

          Makson Lee added a comment -

          should we return SCMRevisionState.NONE instead of null?

          	@Override
          	public SCMRevisionState calcRevisionsFromBuild(
          			@Nonnull final Run<?, ?> build, @Nullable final FilePath workspace,
          			@Nullable final Launcher launcher, @Nonnull final TaskListener listener
          			) throws IOException, InterruptedException {
          		// We add our SCMRevisionState from within checkout, so this shouldn't
          		// be called often. However it will be called if this is the first
          		// build, if a build was aborted before it reported the repository
          		// state, etc.
          		return null;
          }
          

          Makson Lee added a comment - should we return SCMRevisionState.NONE instead of null? @Override public SCMRevisionState calcRevisionsFromBuild( @Nonnull final Run<?, ?> build, @Nullable final FilePath workspace, @Nullable final Launcher launcher, @Nonnull final TaskListener listener ) throws IOException, InterruptedException { // We add our SCMRevisionState from within checkout, so this shouldn't // be called often. However it will be called if this is the first // build, if a build was aborted before it reported the repository // state, etc. return null ; }

          Thomas Keller added a comment -

          Yes, returning (and handling) SCMRevisionState.NONE fixed the issue for me. I created a PR: https://github.com/jenkinsci/repo-plugin/pull/38

          Thomas Keller added a comment - Yes, returning (and handling) SCMRevisionState.NONE fixed the issue for me. I created a PR: https://github.com/jenkinsci/repo-plugin/pull/38

          Code changed in jenkins
          User: Thomas Keller
          Path:
          src/main/java/hudson/plugins/repo/RepoScm.java
          http://jenkins-ci.org/commit/repo-plugin/b760e06a9db62e6f1f2ce7d564b642959411a32f
          Log:
          JENKINS-36703: Fix polling behaviour

          Properly return SCMRevisionState.NONE and handle the cases when
          we get this back from the API.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Thomas Keller Path: src/main/java/hudson/plugins/repo/RepoScm.java http://jenkins-ci.org/commit/repo-plugin/b760e06a9db62e6f1f2ce7d564b642959411a32f Log: JENKINS-36703 : Fix polling behaviour Properly return SCMRevisionState.NONE and handle the cases when we get this back from the API.

          Code changed in jenkins
          User: Robert Sandell
          Path:
          src/main/java/hudson/plugins/repo/ChangeLog.java
          src/main/java/hudson/plugins/repo/ChangeLogEntry.java
          src/main/java/hudson/plugins/repo/ProjectState.java
          src/main/java/hudson/plugins/repo/RepoChangeLogSet.java
          src/main/java/hudson/plugins/repo/RepoScm.java
          src/main/java/hudson/plugins/repo/RevisionState.java
          src/main/java/hudson/plugins/repo/TagAction.java
          http://jenkins-ci.org/commit/repo-plugin/a610ba8a9a6ac5bb2b866d4f920f2f4dccf09b4d
          Log:
          Merge pull request #38 from tommyd3mdi/master

          JENKINS-36703 Fix polling behaviour

          Compare: https://github.com/jenkinsci/repo-plugin/compare/03e4d6110f3c...a610ba8a9a6a

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sandell Path: src/main/java/hudson/plugins/repo/ChangeLog.java src/main/java/hudson/plugins/repo/ChangeLogEntry.java src/main/java/hudson/plugins/repo/ProjectState.java src/main/java/hudson/plugins/repo/RepoChangeLogSet.java src/main/java/hudson/plugins/repo/RepoScm.java src/main/java/hudson/plugins/repo/RevisionState.java src/main/java/hudson/plugins/repo/TagAction.java http://jenkins-ci.org/commit/repo-plugin/a610ba8a9a6ac5bb2b866d4f920f2f4dccf09b4d Log: Merge pull request #38 from tommyd3mdi/master JENKINS-36703 Fix polling behaviour Compare: https://github.com/jenkinsci/repo-plugin/compare/03e4d6110f3c...a610ba8a9a6a

            kellert Thomas Keller
            maksonlee Makson Lee
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: