pipeline-githubnotify-step-plugin
pipeline-githubnotify-step-plugin copied to clipboard
Do not fail step in case commit is not found (422)
Saw a build fail because it was using this step on a merge commit from a PR, which does not exist remotely. That seems like overkill—notification to GitHub should be a best effort.
[Pipeline] End of Pipeline
java.io.IOException: Server returned HTTP response code: 422 for URL: https://api.github.com/repos/…/…/commits/…
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:347)
at org.kohsuke.github.Requester.parse(Requester.java:615)
Caused: java.io.IOException: Server returned HTTP response code: 422 for URL: https://api.github.com/repos/…/…/commits/…
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1944)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1939)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1938)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1508)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
at org.kohsuke.github.Requester.parse(Requester.java:625)
Caused: org.kohsuke.github.HttpException: Server returned HTTP response code: 422, message: 'Unprocessable Entity' for URL: https://api.github.com/repos/…/…/commits/…
at org.kohsuke.github.Requester.parse(Requester.java:646)
at org.kohsuke.github.Requester.parse(Requester.java:607)
at org.kohsuke.github.Requester._to(Requester.java:285)
Caused: org.kohsuke.github.HttpException: {"message":"No commit found for SHA: …","documentation_url":"https://developer.github.com/v3/repos/commits/#get-a-single-commit"}
at org.kohsuke.github.Requester.handleApiError(Requester.java:703)
at org.kohsuke.github.Requester._to(Requester.java:306)
at org.kohsuke.github.Requester.to(Requester.java:247)
at org.kohsuke.github.GHRepository.getCommit(GHRepository.java:973)
at org.jenkinsci.plugins.pipeline.githubstatusnotification.GitHubStatusNotificationStep$Execution.run(GitHubStatusNotificationStep.java:377)
Caused: java.lang.IllegalArgumentException: The specified commit does not exist in the specified repository
at org.jenkinsci.plugins.pipeline.githubstatusnotification.GitHubStatusNotificationStep$Execution.run(GitHubStatusNotificationStep.java:379)
at org.jenkinsci.plugins.pipeline.githubstatusnotification.GitHubStatusNotificationStep$Execution.run(GitHubStatusNotificationStep.java:355)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:290)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
The API docs as usual do not document return codes; GitHub staff has told me in the past that they should be obvious. They are not, but 422 is at least documented for “invalid fields”.
I extended the fix to also cover some cases I have observed where a transient GitHub outage affecting only commit status operations was causing builds to fail, which it should not I think.
@raul-arabaolaza needs to be labelled bug prior to merge
@raul-arabaolaza is this plugin still in use? If not, PRs should be closed and it should be archived I guess?