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

Tag this build fails when attempting to tag a branch that has not changed

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • subversion-plugin
    • None
    • Windows

      1. Start with a repository structure that contains this: http://svn/repos/trunk/mybranch
      2. Create a branch as follows: svn copy http://svn/repos/trunk http://svn/repos/branches/develop
      3. Setup a Hudson job that checks out the workspace from: http://svn/repos/branches/develop/mybranch
      4. Run the job
      5. Try to use the Tag this build function on the build
      6. Tag this build will fail with the error message:

      ERROR: Failed to tag
      org.tmatesoft.svn.core.SVNException: svn: Path 'http://svn/repos/branches/develop/mybranch' does not exist in revision 173,203
      at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:64)
      at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:51)
      at org.tmatesoft.svn.core.internal.wc.SVNCopyDriver.copyReposToRepos(SVNCopyDriver.java:264)
      at org.tmatesoft.svn.core.internal.wc.SVNCopyDriver.setupCopy(SVNCopyDriver.java:628)
      at org.tmatesoft.svn.core.wc.SVNCopyClient.doCopy(SVNCopyClient.java:426)
      at hudson.scm.SubversionTagAction$TagWorkerThread.perform(SubversionTagAction.java:262)
      at hudson.model.TaskThread.run(TaskThread.java:126)
      Completed

      The reason according to my analysis is the fact that the Last Changed Rev is stored instead of the Revision. The Last Changed Rev is created before step 2 above, i.e. it fails because the url http://svn/repos/branches/develop/mybranch does not exist in this revision.

      This has also been identified in this discussion:
      http://jenkins.361315.n4.nabble.com/problem-in-svn-tag-plugin-or-how-hudson-creates-revision-txt-td2965746.html

          [JENKINS-8811] Tag this build fails when attempting to tag a branch that has not changed

          Peter Walls added a comment - - edited

          I think I have found a solution to the error, but since I am not an expert in the code, my changes might very well cause unexpected behaviour in other places. I have tested the original error, and my changes fix these. I have also tested the changes by triggering a build that makes a very long checkout. During the checkout I did a lot of changes in the repo. The plugin still reports the correct revision.

          Below is my suggested change, in the form of a svn diff on https://svn.jenkins-ci.org/trunk/hudson/plugins/subversion@38816. Hopefully this is something you can use!

          Index: src/main/java/hudson/scm/SubversionSCM.java
          ===================================================================
          — src/main/java/hudson/scm/SubversionSCM.java (revision 38816)
          +++ src/main/java/hudson/scm/SubversionSCM.java (working copy)
          @@ -787,7 +787,7 @@
          }

          public SvnInfo(SVNInfo info)

          { - this( info.getURL().toDecodedString(), info.getCommittedRevision().getNumber() ); + this( info.getURL().toDecodedString(), info.getRevision().getNumber() ); }

          public SVNURL getSVNURL() throws SVNException {

          Peter Walls added a comment - - edited I think I have found a solution to the error, but since I am not an expert in the code, my changes might very well cause unexpected behaviour in other places. I have tested the original error, and my changes fix these. I have also tested the changes by triggering a build that makes a very long checkout. During the checkout I did a lot of changes in the repo. The plugin still reports the correct revision. Below is my suggested change, in the form of a svn diff on https://svn.jenkins-ci.org/trunk/hudson/plugins/subversion@38816 . Hopefully this is something you can use! Index: src/main/java/hudson/scm/SubversionSCM.java =================================================================== — src/main/java/hudson/scm/SubversionSCM.java (revision 38816) +++ src/main/java/hudson/scm/SubversionSCM.java (working copy) @@ -787,7 +787,7 @@ } public SvnInfo(SVNInfo info) { - this( info.getURL().toDecodedString(), info.getCommittedRevision().getNumber() ); + this( info.getURL().toDecodedString(), info.getRevision().getNumber() ); } public SVNURL getSVNURL() throws SVNException {

          Peter Walls added a comment -

          The previous correction suggested by me is really a bad idea! The change will mess up SCM polling, making all jobs triggering on SVN changes to build whenever the SVN repo has been changed. We have rolled-back the change and have implemented a more thorough fix. If interested in the change, do not hesitate to contact me.

          Peter Walls added a comment - The previous correction suggested by me is really a bad idea! The change will mess up SCM polling, making all jobs triggering on SVN changes to build whenever the SVN repo has been changed. We have rolled-back the change and have implemented a more thorough fix. If interested in the change, do not hesitate to contact me.

          Are you sure that the URL defined within the scm tag in your pom.xml is correct?
          I had an almost similar issue do to that.

          Martin Stenderup added a comment - Are you sure that the URL defined within the scm tag in your pom.xml is correct? I had an almost similar issue do to that.

          Peter Walls added a comment - - edited

          We made a fix to this bug and we have now been using it extensively without finding any unexpected behaviour. I will attach the one file that we change. The base version that we made the changes to was https://svn.jenkins-ci.org/tags/subversion-1.35/src/main/java/hudson/scm/SubversionTagAction.java.
          I am not a Java programmer, so I am sure that what I have done violates a lot of coding standards and is not fit to be put directly into the Jenkins code base. But you are welcome to it if it helps.

          Peter Walls added a comment - - edited We made a fix to this bug and we have now been using it extensively without finding any unexpected behaviour. I will attach the one file that we change. The base version that we made the changes to was https://svn.jenkins-ci.org/tags/subversion-1.35/src/main/java/hudson/scm/SubversionTagAction.java . I am not a Java programmer, so I am sure that what I have done violates a lot of coding standards and is not fit to be put directly into the Jenkins code base. But you are welcome to it if it helps.

          Peter Walls added a comment -

          File that contains the fix we are using. Our changes were done on revision 40155, i.e. tag 1.35.

          Peter Walls added a comment - File that contains the fix we are using. Our changes were done on revision 40155, i.e. tag 1.35.

          k2nakamura added a comment -

          Peter, I overlooked this issue, but "Tag this build" is not a part of svn-tagging plugin, which I wrote, but a part of core feature, and I'm going to re-assign the default assigner of subversion component.

          k2nakamura added a comment - Peter, I overlooked this issue, but "Tag this build" is not a part of svn-tagging plugin, which I wrote, but a part of core feature, and I'm going to re-assign the default assigner of subversion component.

            Unassigned Unassigned
            peter_walls Peter Walls
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: