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

Error when trying to integrate to non-existing integration branch (Praqma case 13015)

      If you specify an integration branch that doesn't exist on the remote, the plugin fails, with the following error:

      Failed to commit merged changes. Error message below
       (nothing to squash)Already up-to-date.
      HEAD detached at xxxxxxx
      nothing to commit, working directory clean
      

      This is because it does a git checkout -B <integration_branch>
      If the specified integration branch doesn't have a matching branch on the remote, git checkout will happily create a new local branch pointing to the current HEAD without complaining. This is normal and expected git behaviour, but in this case has the obvious side-effect that the resulting merge is empty, as it will be merging from HEAD (the ready branch) to a new branch pointing to the same commit as HEAD.

      As it doesn't really make sense to integrate to a non-existing integration branch, situations like this should be considered configuration errors. The plugin should somehow check that the integration branch exists.

          [JENKINS-28370] Error when trying to integrate to non-existing integration branch (Praqma case 13015)

          Jan Krag added a comment -

          I have two suggestions for solutions:

          1. We change the git checkout line to: git checkout -B <integration> --track origin/<integration>
            This will make it fail if the tracking branch doesn't exist.
          2. The nicer solution would be to separately verify that the branch exists. This would allow printing an explicit, friendly error message. (Also making it much easier to match this specific problem with Failure Cause plugin)
            The best way to check if the branch exists, is git ls-remote --exit-code . origin/<integration>. This will fail with a non-zero exit code if the branch doesn't exist, otherwise print out the sha and branch ref.

          Jan Krag added a comment - I have two suggestions for solutions: We change the git checkout line to: git checkout -B <integration> --track origin/<integration> This will make it fail if the tracking branch doesn't exist. The nicer solution would be to separately verify that the branch exists. This would allow printing an explicit, friendly error message. (Also making it much easier to match this specific problem with Failure Cause plugin) The best way to check if the branch exists, is git ls-remote --exit-code . origin/<integration> . This will fail with a non-zero exit code if the branch doesn't exist, otherwise print out the sha and branch ref.

          Lars Kruse added a comment -

          This issue continues on GitHub Issues - come join us: https://github.com/Praqma/pretested-integration-plugin/issues/8

          Lars Kruse added a comment - This issue continues on GitHub Issues - come join us: https://github.com/Praqma/pretested-integration-plugin/issues/8

            praqma Praqma Support
            madsnielsen Mads Nielsen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: