Provide default value for requestForTestingPhrase#452
Open
hartzell wants to merge 1 commit intojaninko:masterfrom
hartzell:patch-1
Open
Provide default value for requestForTestingPhrase#452hartzell wants to merge 1 commit intojaninko:masterfrom hartzell:patch-1
hartzell wants to merge 1 commit intojaninko:masterfrom
hartzell:patch-1
Conversation
I configure my Jenkinses via a setup.groovy script and never visit the configuration page. Builds are never run for people who are not on the white list and the admin is never asked to approve builds for them. It turns out that the reason is that Jenkins is trying to use the `requestForTesting` phrase but that it has never been set, leading to a `NullPointerException`: ``` Unable to handle comment for PR# 1213, repo: git-workshop/git-workshop.<elided> java.lang.NullPointerException at org.jenkinsci.plugins.ghprb.GhprbRepository.addComment(GhprbRepository.java:238) at org.jenkinsci.plugins.ghprb.GhprbRepository.addComment(GhprbRepository.java:234) at org.jenkinsci.plugins.ghprb.GhprbPullRequest.<init>(GhprbPullRequest.java:139) at org.jenkinsci.plugins.ghprb.GhprbRepository.getPullRequest(GhprbRepository.java:365) at org.jenkinsci.plugins.ghprb.GhprbRepository.onIssueCommentHook(GhprbRepository.java:345) at org.jenkinsci.plugins.ghprb.GhprbTrigger.handleComment(GhprbTrigger.java:611) at org.jenkinsci.plugins.ghprb.GhprbRootAction$1.run(GhprbRootAction.java:233) ``` I'm currently working around the issue like so: ```groovy // Set up the Github Pull Request Builder Plugin // https://gist.github.com/kpettijohn/e294c50e29ca4e8a329e def ghprbDesc = Jenkins.instance.getDescriptorByType(org.jenkinsci.plugins.ghprb.GhprbTrigger.DescriptorImpl.class) // [other settings elided] // Set a value to use when Jenkins asks the admins if it's // ok to run a build from a "stranger". This field has no // default value, so if it's not set here, Jenkins accesses a // null pointer and becomes sad. Field testPlease = ghprbDesc.class.getDeclaredField("requestForTestingPhrase") testPlease.setAccessible(true) testPlease.set(ghprbDesc, "Can one of the admins verify this patch?") ``` but it seems like it would be safer to provide it with a default value like you do for the other phrases. Alternatively, `org.jenkinsci.plugins.ghprb.GhprbRepository.addComment` {sh,c}ould check that it's argument is not null before using it. **But**, that wouldn't help the 'infrastructure as code' crowd as much as my proposed change. It would be really nice if there were a programmatic way to configure the plugin. The `configure` method is tied to a request, so it's not easily usable and using reflection to access the plugin's private bits seems icky.
|
Can one of the admins verify this patch? |
1 similar comment
|
Can one of the admins verify this patch? |
Author
|
Is there anything I can do to help move this along? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I configure my Jenkinses via a setup.groovy script and never visit the configuration page.
Builds are never run for people who are not on the white list and the admin is never asked to approve builds for them.
It turns out that the reason is that Jenkins is trying to use the
requestForTestingphrase but that it has never been set, leading to aNullPointerException:I'm currently working around the issue like so:
but it seems like it would be safer to provide it with a default value like you do for the other phrases.
Alternatively,
org.jenkinsci.plugins.ghprb.GhprbRepository.addComment{sh,c}ould check that it's argument is not null before using it. But, that wouldn't help the 'infrastructure as code' crowd as much as my proposed change.It would be really nice if there were a programmatic way to configure the plugin. The
configuremethod is tied to a request, so it's not easily usable and using reflection to access the plugin's private bits seems icky.