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

GitHubCommitStatusSetter is not reading proper commit id from a shared library

      GitHubCommitStatusSetter is not able to get a proper commitId to update the status on Github, because the commitId that is passed is the head commit for the shared library, instead of the project being built.

       

      Besides that, in the same scenario, I have this code in a shared library:

      String getGitAuthor() {
          def commit = sh(returnStdout: true, script: 'git rev-parse HEAD'); 
          return sh(returnStdout: true, script: "git --no-pager show -s --format='%an' ${commit}").trim();
      } 
      
      String getLastCommitMessage() {
          return sh(returnStdout: true, script: 'git log -1 --pretty=%B').trim();
      }
      

      When running a build consuming the library, then those methods return values for the shared library project, instead of the project that is actually being built. Maybe I'm doing it wrong and I'm not locating the code in the proper place, so please correct me if I'm wrong.

          [JENKINS-53149] GitHubCommitStatusSetter is not reading proper commit id from a shared library

          It is weird: the commitId used to update the github status is properly captured in pull requests, but not on master branch, where the commitId used is the head commit of the shared library.

          Manuel de la Peña added a comment - It is weird: the commitId used to update the github status is properly captured in pull requests, but not on master branch, where the commitId used is the head commit of the shared library.

          Hi lanwen, I noticed the plugin always takes into account the first repository that the build action has. But when there is more than one repository, i.e. when loading a shared library, then it would be necessary to inspect the repos, and verify if they relate to the proper repository, which is the project's one.

          I sent a possible fix here: https://github.com/jenkinsci/github-plugin/pull/198

          Thanks!

          Manuel de la Peña added a comment - Hi  lanwen , I noticed the plugin always takes into account the first repository that the build action has. But when there is more than one repository, i.e. when loading a shared library, then it would be necessary to inspect the repos, and verify if they relate to the proper repository, which is the project's one. I sent a possible fix here: https://github.com/jenkinsci/github-plugin/pull/198 Thanks!

          The proposed solution has been merged

          Manuel de la Peña added a comment - The proposed solution has been merged

            lanwen Kirill Merkushev
            mdelapenya Manuel de la Peña
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: