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

Usage of ObjectID.fromString in computeMergeChangeLog leads to "java.lang.IllegalArgumentException: Invalid id"

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: git-plugin
    • Labels:
      None
    • Environment:
      Jenkins ver. 1.480.3, Git Plugin 1.1.29
    • Similar Issues:

      Description

      When configuring a Jenkins job with "merge before build" and setting "Branch to merge to" to develop, the job fails with an "IllegalArgumentException: Invalid id".

      In the class hudson.plugins.git.GitSCM the method computeMergeChangeLog is called with the remote branch name as third paramater (called revFrom in the method declaration). In the method computeMergeChangeLog the following code is executed:

      if (!git.isCommitInRepo(ObjectId.fromString(revFrom)))

      { ... }

      If revFrom is the remote branch name (e.g. "origin/develop"), the fromString method of the JGit class ObjectId throws the IllegalArgumentException because "origin/develop" does not have a length of 40.
      ObjectId.fromString obviously expects a Git commit ID - which has a length of 40 characters - and not the name of a branch ref.

      The bug was introduced with 1.1.27. Installing 1.1.26 fixed the problem.

        Attachments

          Activity

          Hide
          ndeloof Nicolas De Loof added a comment -

          thanks for detailled analysis, I will investigate for a fix

          Show
          ndeloof Nicolas De Loof added a comment - thanks for detailled analysis, I will investigate for a fix
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Nicolas De Loof
          Path:
          src/main/java/hudson/plugins/git/GitSCM.java
          src/main/test/hudson/plugins/git/SubmoduleCombinatorTest.java
          src/test/java/hudson/plugins/git/AbstractGitTestCase.java
          src/test/java/hudson/plugins/git/GitSCMTest.java
          src/test/java/hudson/plugins/git/TestGitRepo.java
          http://jenkins-ci.org/commit/git-plugin/128f715dbae13ceb54ad36d38b584e3e1b309d26
          Log:
          [FIXED JENKINS-16888] compute ObjectId before checking isCommitInRepo
          added unit tests to cover

          • fetch from multiple repositories JENKINS-16914
          • merge basic scenario
          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/main/java/hudson/plugins/git/GitSCM.java src/main/test/hudson/plugins/git/SubmoduleCombinatorTest.java src/test/java/hudson/plugins/git/AbstractGitTestCase.java src/test/java/hudson/plugins/git/GitSCMTest.java src/test/java/hudson/plugins/git/TestGitRepo.java http://jenkins-ci.org/commit/git-plugin/128f715dbae13ceb54ad36d38b584e3e1b309d26 Log: [FIXED JENKINS-16888] compute ObjectId before checking isCommitInRepo added unit tests to cover fetch from multiple repositories JENKINS-16914 merge basic scenario
          Hide
          karianna karianna added a comment -

          We were forced to run the latest plugin from HEAD (1.3.0-SNAPSHOT) - resolved the issue for us!

          Show
          karianna karianna added a comment - We were forced to run the latest plugin from HEAD (1.3.0-SNAPSHOT) - resolved the issue for us!

            People

            • Assignee:
              ndeloof Nicolas De Loof
              Reporter:
              user0815 Torsten Beuck
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: