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

Issue with latest subversion plugin (1.13). Maybe with 1.14 also

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Component/s: subversion-plugin
    • Labels:
      None
    • Environment:
      windows xp sp2, sun JAVA 1.6.0_16, apache tomcat 5.5
    • Similar Issues:

      Description

      Problem: If you setup a project of type: "Build a free-style software project" with subversion set AND POLL SCM checked with 1 minute testing interval (CRON/INTERVAL OF: "* * * * *"), everything will work fine as long as subversion server is available. However, if the subversion server is not available because the svn server is simply not running or the network access is not there, then the first minute SCM POLLING log under the project, you will see the SVNException caused by java.net.ConnectException and the outcome of "No changes". Then, when the second minute SCM POLLING happens, the outcome will be "Changes found". Thus, a build will be queued and the build will fail because the svn server is not accessible/available.

      Expected Behavior: I was expecting subversion plugin to simply detect that the svn server is not available and just conclude that subversion plugin cannot determine if a build is needed.

      HERE IS THE FIX I CREATED:

      Within SubversionSCM.java:

                  public PollingResult call() throws IOException {
                      final Map<String,Long> revs = new HashMap<String,Long>();
                      boolean changes = false;
                      boolean significantChanges = false;
      
                      for (Map.Entry<String,Long> baselineInfo : baseline.revisions.entrySet()) {
                          String url = baselineInfo.getKey();
                          long baseRev = baselineInfo.getValue();
      
                          try {
                              final SVNURL svnurl = SVNURL.parseURIDecoded(url);
                              long nowRev = new SvnInfo(parseSvnInfo(svnurl,authProvider)).revision;
      
                              changes |= (nowRev>baseRev);
      
                              listener.getLogger().println(Messages.SubversionSCM_pollChanges_remoteRevisionAt(url, nowRev));
                              revs.put(url, nowRev);
                              // make sure there's a change and it isn't excluded
                              if (logHandler.findNonExcludedChanges(svnurl,
                                      baseRev+1, nowRev, authProvider)) {
                                  listener.getLogger().println(Messages.SubversionSCM_pollChanges_changedFrom(baseRev));
                                  significantChanges = true;
                              }
                          } catch (SVNException e) {
      						// DEFECT FIX:  This is a fix to address the issue of when the svn repository is unavailable.
      						//              The bug happens due to the SubversionSCM logic thinking a build is needed when
      						//              really we do not have any information from remote SVN repository to determine this.
      						// Author:  Jeffrey Lutz bulkmail@lutz.ws
                              // If SVNException was caused by connection failure to subversion, then make sure to make
                              // "current" SVNRevisionState is like "baseline" SVNRevisionState with regards to revisions
                              //
                              if(e.getCause() instanceof java.net.ConnectException) {
                                  revs.put(url, baseRev);
                              }
                              e.printStackTrace(listener.error(Messages.SubversionSCM_pollChanges_exception(url)));
                          }
                      }
      
                      assert revs.size()== baseline.revisions.size();
      
                      Change currentChange = significantChanges ? Change.SIGNIFICANT : changes ? Change.INSIGNIFICANT : Change.NONE;
      
                      return new PollingResult(baseline, new SVNRevisionState(revs), currentChange);
                  }
      

        Attachments

          Activity

          Hide
          jeffreylutz jeffreylutz added a comment -

          Here is the complete fixed SubversionSCM.java

          Show
          jeffreylutz jeffreylutz added a comment - Here is the complete fixed SubversionSCM.java
          Hide
          kohsuke Kohsuke Kawaguchi added a comment -

          I thought about this and I decided to fix it bit differently. I don't see any reason to restrict this just to the connection problem. If the access to the server is broken to the point that we can't even retrieve a revision number, any attempts down the road to update/checkout would likely to fail. If you can check the diff, that would be great.

          Show
          kohsuke Kohsuke Kawaguchi added a comment - I thought about this and I decided to fix it bit differently. I don't see any reason to restrict this just to the connection problem. If the access to the server is broken to the point that we can't even retrieve a revision number, any attempts down the road to update/checkout would likely to fail. If you can check the diff, that would be great.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in hudson
          User: : kohsuke
          Path:
          trunk/hudson/plugins/subversion/src/main/java/hudson/scm/SubversionSCM.java
          http://jenkins-ci.org/commit/29661
          Log:
          [FIXED JENKINS-6136] if an error happens during the polling, don't let that produce bogus build attempts.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in hudson User: : kohsuke Path: trunk/hudson/plugins/subversion/src/main/java/hudson/scm/SubversionSCM.java http://jenkins-ci.org/commit/29661 Log: [FIXED JENKINS-6136] if an error happens during the polling, don't let that produce bogus build attempts.
          Hide
          axelheider Axel Heider added a comment -

          Could you extend this to optionally trigger an e-mail notification, so the admin becomes aware of the
          problem? Such a notification could include:

          • connection error [first SCM polling fails, subsequent polling error are not reported]
          • connection error [every time SCM polling fails]
          • connection avaialble again after error
          Show
          axelheider Axel Heider added a comment - Could you extend this to optionally trigger an e-mail notification, so the admin becomes aware of the problem? Such a notification could include: connection error [first SCM polling fails, subsequent polling error are not reported] connection error [every time SCM polling fails] connection avaialble again after error

            People

            • Assignee:
              Unassigned
              Reporter:
              jeffreylutz jeffreylutz
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: