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

Report failures to attach hook in UI

XMLWordPrintable

      When GitHubPushTrigger.start is run (generally because a job configuration was just saved), it forks a thread to update the web hooks. If there are any problems doing that, these are sent to the system log, but the person configuring the job may not know to look there (or may not even have permissions to do so). For example, I have gotten stack traces like

      Failed to obtain repository com.cloudbees.jenkins.GitHubRepositoryName$1$1@...
      java.io.IOException: {"message":"Bad credentials","documentation_url":"https://developer.github.com/v3"}
          at org.kohsuke.github.Requester.handleApiError(Requester.java:427)
          at org.kohsuke.github.Requester._to(Requester.java:206)
          at org.kohsuke.github.Requester.to(Requester.java:160)
          at org.kohsuke.github.GitHub.getUser(GitHub.java:279)
          at com.cloudbees.jenkins.GitHubRepositoryName$1$1.adapt(GitHubRepositoryName.java:101)
          at com.cloudbees.jenkins.GitHubRepositoryName$1$1.adapt(GitHubRepositoryName.java:98)
          at hudson.util.AdaptedIterator.next(AdaptedIterator.java:54)
          at hudson.util.Iterators$FilterIterator.fetch(Iterators.java:109)
          at hudson.util.Iterators$FilterIterator.hasNext(Iterators.java:127)
          at com.cloudbees.jenkins.GitHubPushTrigger$2.run(GitHubPushTrigger.java:144)
          at ...
      Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: https://api.github.com/users/<myorg>
          at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
          at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
          at org.kohsuke.github.Requester.parse(Requester.java:383)
          at org.kohsuke.github.Requester._to(Requester.java:185)
          ... 16 more
      

      and later on the same job

      org.kohsuke.github.GHException: Failed to update jenkins hooks
          at com.cloudbees.jenkins.GitHubPushTrigger.createJenkinsHook(GitHubPushTrigger.java:164)
          at com.cloudbees.jenkins.GitHubPushTrigger.access$700(GitHubPushTrigger.java:46)
          at com.cloudbees.jenkins.GitHubPushTrigger$2.run(GitHubPushTrigger.java:146)
          at ...
      Caused by: java.io.FileNotFoundException: https://api.github.com/repos/<myorg>/<myrepo>/hooks
          at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
          at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
          at org.kohsuke.github.Requester.parse(Requester.java:383)
          at org.kohsuke.github.Requester._to(Requester.java:185)
          at org.kohsuke.github.Requester.to(Requester.java:160)
          at org.kohsuke.github.GHRepository.createHook(GHRepository.java:754)
          at com.cloudbees.jenkins.GitHubPushTrigger.createJenkinsHook(GitHubPushTrigger.java:161)
          ... 10 more
      

      By the time these are thrown, it is of course too late to display such errors on the configuration page for the job now, but I would suggest that form validation for the push trigger display any such errors from the last save. (If you are not getting builds triggered, your natural first step would be to double-check the job configuration, where you would see this clearly.)

            lanwen Kirill Merkushev
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: