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

Git operations fail after global lib is loaded

      We have a single global library defined loaded from github. When we're running longer-running builds, we set the status of the commit using the GitHubCommitStatusSetter step:

      step([$class: 'GitHubCommitStatusSetter', statusResultSource: [$class: 'ConditionalStatusResultSource', results: []]])
      

      Say the library is called LIB and the project we're building (also on github) is APP, when the above step is executed it tries to set the commit status with the commit-hash from APP on the repository LIB, which then fails because the LIB doesn't have this commit hash.

       org.jenkinsci.plugins.github.common.CombineErrorHandler$ErrorHandlingException: java.io.FileNotFoundException: {"message":"No commit found for SHA: 172fd52d6393fae44ee1d962dc26098846489e1e","documentation_url":"https://developer.github.com/v3/repos/statuses/"}
      

      I think I can around this by explicitly specifying the repository in the GitHubCommitStatusSetter but ideally that shouldn't be necessary.

          [JENKINS-40150] Git operations fail after global lib is loaded

          Kanstantsin Shautsou added a comment - - edited

          Workflow, cps or whatever it is probably should set context of executed code to job. I see nothing that github-plugin could do for workflow magic. If somebody will know solution, issue could get github-plugin component back.

          Kanstantsin Shautsou added a comment - - edited Workflow, cps or whatever it is probably should set context of executed code to job. I see nothing that github-plugin could do for workflow magic. If somebody will know solution, issue could get github-plugin component back.

          Jesse Glick added a comment -

          Use status notifications from github-branch-source, which will track SCMRevisionAction, or make GitHubCommitStatusSetter do the same.

          Jesse Glick added a comment - Use status notifications from github-branch-source , which will track SCMRevisionAction , or make GitHubCommitStatusSetter do the same.

          I'll add provider

          Kirill Merkushev added a comment - I'll add provider

          Can you add more detailed example?

          I'm not very familiar with pipeline ecosystem, so it will be very helpful if i can reproduce exact your usecase.

          Kirill Merkushev added a comment - Can you add more detailed example? I'm not very familiar with pipeline ecosystem, so it will be very helpful if i can reproduce exact your usecase.

          Hi,

          I encounter a related but different issue. If I use an external pipeline library (via Jenkinsfile), github notifications are pushed with pipeline library's SHA instead of project SHA.
          I succeed to workaround it with a quick and dirty fix : https://github.com/lalmeras/github-plugin/commit/2f038d249bc142163b2866cf863ebb27ee49c629
          As jglick suggests, it use SCMRevisionAction in place of BuildData.

          I think github plugin should provide at least a GitHubCommitShaSource implementation that handles SCMRevisionAction. It also seems to me that SCMRevisionAction may be a better default as other plugins switch to it for the same reason : https://issues.jenkins-ci.org/browse/JENKINS-42809

          About gijsk's problem I think it is not related to pipeline's library, so he may need to handle manually SHA with this help https://wiki.jenkins-ci.org/display/JENKINS/Github+Plugin#GitHubPlugin-Settingcommitstatus

          Laurent Almeras added a comment - Hi, I encounter a related but different issue. If I use an external pipeline library (via Jenkinsfile), github notifications are pushed with pipeline library's SHA instead of project SHA. I succeed to workaround it with a quick and dirty fix : https://github.com/lalmeras/github-plugin/commit/2f038d249bc142163b2866cf863ebb27ee49c629 As jglick suggests, it use SCMRevisionAction in place of BuildData. I think github plugin should provide at least a GitHubCommitShaSource implementation that handles SCMRevisionAction. It also seems to me that SCMRevisionAction may be a better default as other plugins switch to it for the same reason : https://issues.jenkins-ci.org/browse/JENKINS-42809 About gijsk 's problem I think it is not related to pipeline's library, so he may need to handle manually SHA with this help https://wiki.jenkins-ci.org/display/JENKINS/Github+Plugin#GitHubPlugin-Settingcommitstatus

          I post on https://issues.jenkins-ci.org/browse/JENKINS-42809 as it seems to me that BuildData's behavior change (it now exposes pipeline's lib information instead of project information) may need to be reworked or explain before we can fix this issue.

          If anyone could confirm or refute my analysis ?

          Laurent Almeras added a comment - I post on https://issues.jenkins-ci.org/browse/JENKINS-42809 as it seems to me that BuildData's behavior change (it now exposes pipeline's lib information instead of project information) may need to be reworked or explain before we can fix this issue. If anyone could confirm or refute my analysis ?

          Jesse Glick added a comment -

          BuildData's behavior change (it now exposes pipeline's lib information instead of project information)

          No, it exposes both. In general there could be any number of BuildData attached to a given build. It is up to the caller to select which BuildData it cares about; or use SCMRevisionAction if it is specifically looking for the multibranch commit.

          Jesse Glick added a comment - BuildData's behavior change (it now exposes pipeline's lib information instead of project information) No, it exposes both. In general there could be any number of BuildData attached to a given build. It is up to the caller to select which BuildData it cares about; or use SCMRevisionAction if it is specifically looking for the multibranch commit.

          Thanks for your insight on BuildData. I'll try to figure out the best way to handle my case (lookup SHA from project repo to set commit status when a pipeline's lib is used).

          Laurent Almeras added a comment - Thanks for your insight on BuildData. I'll try to figure out the best way to handle my case (lookup SHA from project repo to set commit status when a pipeline's lib is used).

            lanwen Kirill Merkushev
            gijsk Gijs Kunze
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: