• Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major Major
    • mercurial-plugin
    • None

      When using a tag as the branch with mercurial, in some cases, the build will fail (example bellow).

      This is because the branch is used as a param to "hg incoming". Only the revisions up to the tagged one are pulled in the local clone. Since the tag is set in a changeset after the tagged revision itself, the tag name becomes unknown to the local clone -> The hg command that use the tag fails.

      The only solution I know is to avoid using "--rev" for the incoming command (same for pull).
      The drawback is that more changesets than needed will be retrieved, but at least we are sure to have the required ones.

      Example of log (TAG is set to "5.131-p18"):

      [Starform-6.0] $ hg incoming --quiet --bundle hg.bundle --template "<changeset node='

      {node}

      ' author='

      {author|xmlescape}

      ' rev='

      {rev}

      ' date='

      {date}

      '><msg>

      {desc|xmlescape}

      </msg><added>

      {file_adds|stringify|xmlescape}

      </added><deleted>

      {file_dels|stringify|xmlescape}

      </deleted><files>

      {files|stringify|xmlescape}

      </files><parents>

      {parents}

      </parents></changeset>\n" --rev ${TAG}
      [Starform-6.0] $ hg unbundle hg.bundle
      adding changesets
      adding manifests
      adding file changes
      added 12 changesets with 13 changes to 3 files (+1 heads)
      (run 'hg heads' to see heads, 'hg merge' to merge)
      [Starform-6.0] $ hg update --clean --rev ${TAG}
      abort: unknown revision '5.131-p18'!

      (jglick, I assigned you the issue since you seem to be maintaining the plugin)

          [JENKINS-5396] Support tags instead of branches

          Since this feature is still not implemented, I've found a work-around which works for me:

          Configure the 'default' Branch in the job and configure a 'windows command' or 'shell script' as first build step which executes: hg update -r TAGNAME

          Rick Oosterholt added a comment - Since this feature is still not implemented, I've found a work-around which works for me: Configure the 'default' Branch in the job and configure a 'windows command' or 'shell script' as first build step which executes: hg update -r TAGNAME

          Jakob Malm added a comment -

          @ricktw A downside is that Jenkins won't record the correct changeset...

          Jakob Malm added a comment - @ricktw A downside is that Jenkins won't record the correct changeset...

          Martin Fiers added a comment -

          This also affects us. There are many workarounds displayed here, but as discussed, they do not really give a nice solution.

          "Probably the user will have to indicate a tag in a separate field (mutually exclusive), or check a box saying that the branch field should be treated as a tag."

          This looks like a clean solution... So why not implement it for those that need it? (there's even blogs about possible ways to circumvent this problem, so I guess there's enough people that would benefit from it).

          The only thing that probably has to change in case this option is selected, is to remove the `cmd.add("--rev", branch);` line in main/java/hudson/plugins/mercurial/MercurialSCM.java on line 318.

          https://github.com/jenkinsci/mercurial-plugin/blob/master/src/main/java/hudson/plugins/mercurial/MercurialSCM.java#L321

          Unfortunately, trying to modify the code ourselves and installing the created hpi file manually messed up our jenkins installation.

          Martin Fiers added a comment - This also affects us. There are many workarounds displayed here, but as discussed, they do not really give a nice solution. "Probably the user will have to indicate a tag in a separate field (mutually exclusive), or check a box saying that the branch field should be treated as a tag." This looks like a clean solution... So why not implement it for those that need it? (there's even blogs about possible ways to circumvent this problem, so I guess there's enough people that would benefit from it). The only thing that probably has to change in case this option is selected, is to remove the `cmd.add("--rev", branch);` line in main/java/hudson/plugins/mercurial/MercurialSCM.java on line 318. https://github.com/jenkinsci/mercurial-plugin/blob/master/src/main/java/hudson/plugins/mercurial/MercurialSCM.java#L321 Unfortunately, trying to modify the code ourselves and installing the created hpi file manually messed up our jenkins installation.

          Jesse Glick added a comment -

          So why not implement it for those that need it?

          That is my plan. No time in October, hope to have more time in November.

          Jesse Glick added a comment - So why not implement it for those that need it? That is my plan. No time in October, hope to have more time in November.

          Any news on this implementation yet? We also need this feature.

          Hermien Pellissier added a comment - Any news on this implementation yet? We also need this feature.

          Jesse Glick added a comment -

          No time this week. Still on my list.

          Jesse Glick added a comment - No time this week. Still on my list.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          src/main/java/hudson/plugins/mercurial/MercurialSCM.java
          src/main/resources/hudson/plugins/mercurial/MercurialSCM/config.jelly
          src/main/resources/hudson/plugins/mercurial/MercurialSCM/help-branch.html
          src/main/resources/hudson/plugins/mercurial/MercurialSCM/help-revision.html
          src/main/resources/hudson/plugins/mercurial/MercurialSCM/help-revisionType.html
          src/test/java/hudson/plugins/mercurial/SCMTestBase.java
          http://jenkins-ci.org/commit/mercurial-plugin/a1d636a76bbcd99a7ee11e6460da3c2240030d42
          Log:
          [FIXED JENKINS-5396] Added supported option to update to a tag rather than a branch.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/hudson/plugins/mercurial/MercurialSCM.java src/main/resources/hudson/plugins/mercurial/MercurialSCM/config.jelly src/main/resources/hudson/plugins/mercurial/MercurialSCM/help-branch.html src/main/resources/hudson/plugins/mercurial/MercurialSCM/help-revision.html src/main/resources/hudson/plugins/mercurial/MercurialSCM/help-revisionType.html src/test/java/hudson/plugins/mercurial/SCMTestBase.java http://jenkins-ci.org/commit/mercurial-plugin/a1d636a76bbcd99a7ee11e6460da3c2240030d42 Log: [FIXED JENKINS-5396] Added supported option to update to a tag rather than a branch.

          I installed the experimental plugin with this change, and it works beautifully. Thanks Jesse!

          Hermien Pellissier added a comment - I installed the experimental plugin with this change, and it works beautifully. Thanks Jesse!

          cowwoc added a comment -

          (Confused) Is this fix part of the public plugin? Or is it not released to the public yet? Last time I checked I didn't see a separate "tag" UI field.

          cowwoc added a comment - (Confused) Is this fix part of the public plugin? Or is it not released to the public yet? Last time I checked I didn't see a separate "tag" UI field.

          Jesse Glick added a comment -

          It is currently only on the experimental update center. I can push a general 1.50 release, though; probably about time.

          Jesse Glick added a comment - It is currently only on the experimental update center. I can push a general 1.50 release, though; probably about time.

            jglick Jesse Glick
            cdevienne cdevienne
            Votes:
            15 Vote for this issue
            Watchers:
            19 Start watching this issue

              Created:
              Updated:
              Resolved: