github-integration-plugin icon indicating copy to clipboard operation
github-integration-plugin copied to clipboard

No way to update github pull status in downstream jobs?

Open codernavi18 opened this issue 8 years ago • 1 comments

I have setup a job to listen for dummy project for pull requests. Once a trigger comes, this job builds the code and then triggers a downstream test job. The test job decides the quality of the pull request received. Then I upload the test result on github pull request page.

Now there are 2 ways to implement this:

First way is, I add a downStreamParameterized() in steps{}. This way I am able to publish the results on github from this job, once the result comes back from the downstream test job. But the disadvantage is that, while testjob is being executed, the parent job is blocked. This is a wastage of resource if the 2 jobs are running on 2 different nodes.

Second way is, I add downStreamParameterized() in publishers{}. This way parent job can exit (and the parent node also gets free) and trigger the downstream testjob. But the problem is now downstream testjob is not able to publish the status on Github as it was not triggerd by a pull request but rather its a downstream job. Hence, it crashes with Exception :

java.lang.NullPointerException
	at org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRBuildStatusPublisher.perform(GitHubPRBuildStatusPublisher.java:94)
	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
	at hudson.model.Build$BuildExecution.post2(Build.java:186)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
	at hudson.model.Run.execute(Run.java:1753)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:405)
Build step 'GitHub PR: set PR status' marked build as failure

Does the plugin support this? If yes, please suggest a better way so that parent jobs are not blocked till downstream jobs have returned or if there is a way to publish through downstream jobs, that's also convenient.

codernavi18 avatar May 12 '17 06:05 codernavi18

for settings statuses job is required to have trigger and be triggered by it, downstreamParametrise obviously doesn't copy action has no trigger with associated repo. You need make some custom status setter. In groovy system script it maybe get job that triggered run, get trigger from it, get gH repository and set status for it, should be only few lines of code.

KostyaSha avatar May 26 '17 16:05 KostyaSha