Bug: Downstream job fails to update upstream pr
I have one job building PR's and it works great, updates commit status on GitHub as expected. It also triggers the downstream job correctly, but the downstream job is not able to update the commit status of the pr that triggered the upstream job.
In the upstream job I have checked the advanced option: Display build errors on downstream builds?
In the downstream job I have checked: Set GitHub commit status with custom context and message (Must configure upstream job using GHPRB trigger)
In the jenkins log I get:
INFO: downstream_job #62 main build action completed: SUCCESS
Apr 21, 2016 11:03:00 AM org.jenkinsci.plugins.ghprb.upstream.GhprbUpstreamStatusListener updateEnvironmentVars
SEVERE: Unable to connect to GitHub repo
java.lang.NullPointerException
at org.kohsuke.github.GitHub.getRepository(GitHub.java:334)
at org.jenkinsci.plugins.ghprb.upstream.GhprbUpstreamStatusListener.updateEnvironmentVars(GhprbUpstreamStatusListener.java:78)
at org.jenkinsci.plugins.ghprb.upstream.GhprbUpstreamStatusListener.onCompleted(GhprbUpstreamStatusListener.java:119)
at org.jenkinsci.plugins.ghprb.upstream.GhprbUpstreamStatusListener.onCompleted(GhprbUpstreamStatusListener.java:34)
at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:201)
at hudson.model.Run.execute(Run.java:1783)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
I've tried upgrading to version 1.31.4, but the issue is the same.
@janinko Anything I can do to assist figuring out this bug or have I completely misunderstood what the option: "Set GitHub commit status with custom context and message" is for? I have use cases where the downstream job is using the same repository as upstream job and not. Both cases fail with the same stacktrace.
I have the exact same issue.
The problem is that the various ghprb* parameters are not set on the downstream job.
I added them manually in the trigger Downstream Parametrized job, and it seems to be working now.
While on this topic, I use the Multijob plugin to trigger other jobs in parallel and series. I pass the context name as environment variable and seems like the downstream job does not update the context back on github even though I have enabled the Display build errors on downstream builds? in the main job and Set GitHub commit status with custom context and message (Must configure upstream job using GHPRB trigger)
PS: I am using the environment variables passed by the main job to the sub job to set different contexts. Imagine a subjob to be a single job that runs in the same workspace as the main job but executing different make targets. The make target names and contexts are passed by the main job to the generic job.
I see that ghprbCommitStatusContext has been passed correctly from the main job to the sub job.
ghprbAddTestResults false
ghprbCommitStatusContext nodejs_lib - lint
ghprbERRORMessage Error
ghprbFAILUREMessage Failure
ghprbShowMatrixStatus false
ghprbStartedStatus go! go! go!
ghprbSUCCESSMessage Success
ghprbTriggeredStatus Get! Set!
ghprbUpstreamStatus true
This approached worked flawlessly in Jenkins 1.6xx and ghprb 1.29.6 but not with jenkins 2.7.1 and ghprb 1.33.1
Thanks @masterzen, it works! For anyone that stumbles upon this in the future, here are the parameters that make this work (maybe some of them are unnecessary but didn't feel like trying subsets of this):
sha1=${sha1}
ghprbActualCommit=${ghprbActualCommit}
ghprbAuthorRepoGitUrl=${ghprbAuthorRepoGitUrl}
ghprbCredentialsId=${ghprbCredentialsId}
ghprbPullId=${ghprbPullId}
ghprbGhRepository=${ghprbGhRepository}
ghprbSourceBranch=${ghprbSourceBranch}
ghprbTargetBranch=${ghprbTargetBranch}
I'm seeing same thing. @m-kostrzewa What did you use to pass these environment variables?
@Townsheriff
In upstream project, you can either trigger a parametrized build with
- "Predefined parameters" exactly the same as I wrote in post above
- or a cleaner option that I discovered more recently: just use "Current build parameters"
In downstream project it's pretty ugly: Tick "This project is parameterized", and add a String parameter for every parameter I mentioned in the post above. This means that your job will have at least 8 parameters: sha1, ghprbActualCommit, ghprbAuthorRepoGitUrl etc. (maybe it can have less - if you can trim down the number, please let me know).
Ugh. Yeah. Having to add 8 parameters to every downstream job sucks. It's tedious for one and it's a slew of parameters that people who just want to do a non-GH-PR driven build have to wade through.
Is there no better way to get upstream/downstream GH-PR notification working?
I hit the same issue and I'd like to avoid the workaround with additional 8 parameters. I'm using plugin 1.36.2 on jenkins 2.46.2.
BTW: the parameters workaround does work...
@agherzan it's way more manageable if you use something like the Jenkins Jobs DSL plugin to automate/script your jobs. One can probably do the same thing with the Pipeline module.
I now hit another issue - builds don't update when failed/succeeded. Does that work for you guys?
@agherzan yea, we had to add relevant repos (and creds) in "Source Code Management".
TBH, if we were to implement our CI today, we would've went with @masterzen's suggestion.
I'm just hoping that it is a temporary solution. I'm truly confused how this bug is in needs verification since 30 Sep 2016.
@m-kostrzewa But the starting build status is pushed correctly. Just the build result doesn't go through.
I added the relevant repos and creds to SCM too and still no build results: https://github.com/agherzan/meta-raspberrypi/pull/66
Have no idea what I did but it works not. @m-kostrzewa it seems you don't need SCM configuration in the downstream jobs. Looks good now.
@m-kostrzewa
I have follow steps below which you mention :
In upstream project, you can either trigger a parametrized build with
"Predefined parameters" exactly the same as I wrote in post above or a cleaner option that I discovered more recently: just use "Current build parameters" In downstream project it's pretty ugly: Tick "This project is parameterized", and add a String parameter for every parameter I mentioned in the post above. This means that your job will have at least 8 parameters: sha1, ghprbActualCommit, ghprbAuthorRepoGitUrl
I am using downstream job with different repo. Let me know anything else I need to do because I am not able to update my downstream build status at git commit.
@jayeshkhairnar
Make sure you've added all relevant repos (and creds) in "Source Code Management" in the very top level job. And make sure that you have ghprb plugin set in downstream job to update the build status. Other than that, try debugging by going into the build and looking into Environment Variables - you should see a lot of ones starting with ghprb*
@m-kostrzewa Thanks for your help. It's working fine now. Now I want to upload screenshot to git commit from downstream job. I am running selenium test cases on downstream job and I want upload screenshot of error page with git commit status. Please advsie me on it.
@jayeshkhairnar Nice to hear! Regarding you other question, I would advise asking selenium guys about it. There's very little chance anyone in this thread would be able to help.
@m-kostrzewa you are a life saver! I have been able to get it functional with just these three env variables:
ghprbActualCommit=${ghprbActualCommit}
ghprbPullId=${ghprbPullId}
ghprbGhRepository=${ghprbGhRepository}
I get this strange message at the bottom of the console:
Unable to get pull request builder trigger!!
But it does work, the status is set correctly with these variables, thanks for your post! Does anyone know if a proper fix is actually being implemented?
@martijnhjk glad I could help and thanks for narrowing down the required parameters :+1:
Does anyone know if this can be used to set a Build Status as well? I can get Commit Status to be set by my downstream job, but I dont see how to set the Build Status such that a comment is made on my PR.
an issue not fixed in 6 years ??