Skip to content

JENKINS-55920: add CasC support to GitHubPluginConfig. - #205

Closed
dgarzon wants to merge 3 commits into
jenkinsci:masterfrom
dgarzon:HOTFIX-add-casc-support
Closed

JENKINS-55920: add CasC support to GitHubPluginConfig.#205
dgarzon wants to merge 3 commits into
jenkinsci:masterfrom
dgarzon:HOTFIX-add-casc-support

Conversation

@dgarzon

@dgarzon dgarzon commented Feb 1, 2019

Copy link
Copy Markdown
Contributor

This PR addresses the issue raised in the configuration-as-code-plugin: jenkinsci/configuration-as-code-plugin#672.


This change is Reviewable

@oleg-nenashev

oleg-nenashev commented Feb 1, 2019 via email

Copy link
Copy Markdown
Member

@dgarzon

dgarzon commented Feb 1, 2019

Copy link
Copy Markdown
Contributor Author

@dgarzon dgarzon changed the title HOTFIX: add CasC support to GitHubPluginConfig. JENKINS-55920: add CasC support to GitHubPluginConfig. Feb 1, 2019
@dgarzon
dgarzon force-pushed the HOTFIX-add-casc-support branch from ed81fa2 to 4bed1b8 Compare February 1, 2019 19:39
@oleg-nenashev

oleg-nenashev commented Feb 1, 2019 via email

Copy link
Copy Markdown
Member

@oleg-nenashev oleg-nenashev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binary compat issue needs to be fixed before the merge

Comment thread src/main/java/org/jenkinsci/plugins/github/config/GitHubPluginConfig.java Outdated
Comment thread src/main/java/org/jenkinsci/plugins/github/config/GitHubPluginConfig.java Outdated
@dgarzon
dgarzon force-pushed the HOTFIX-add-casc-support branch from 9390573 to da5d737 Compare February 1, 2019 20:24
@dgarzon

dgarzon commented Feb 1, 2019

Copy link
Copy Markdown
Contributor Author

@oleg-nenashev I tested the hpi and keeping the old setter does not work, as it is picked up by
CasC even though it is not annotated. Any ideas why?

@dgarzon

dgarzon commented Feb 1, 2019

Copy link
Copy Markdown
Contributor Author

@oleg-nenashev actually, it does work. The only thing we needed was annotating setOverrideHookUrl with @DataBoundSetter and exposing a getter. Now CasC works as expected 👍

@dgarzon
dgarzon force-pushed the HOTFIX-add-casc-support branch from da5d737 to 5a6ccd4 Compare February 1, 2019 20:52

@oleg-nenashev oleg-nenashev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good


@DataBoundConstructor
public GitHubPluginConfig() {
load();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataBoundConstructor is used for binding new data, load() is loading old data. Thats looks wrong

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the constructor being used by CasC, and it uses the getter and setter to mutate the instance. The other constructor would make List<GitHubServerConfig> configs required, which should not. What do you suggest would be an appropriate fix to address your concerns?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jglick could you describe why DBC is set on top of Bean constructor that loads data?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong; the annotation should be deleted. GitHubPluginConfig is a singleton (GlobalConfiguration) so it may have @DataBoundSetters but that is it.


@DataBoundConstructor
public GitHubPluginConfig() {
load();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong; the annotation should be deleted. GitHubPluginConfig is a singleton (GlobalConfiguration) so it may have @DataBoundSetters but that is it.

@jglick

jglick commented Feb 6, 2019

Copy link
Copy Markdown
Member

BTW I strongly recommend inclusion of a functional test in PRs like this. There are several examples to look at of plugins which have a test dep on configuration-as-code for this purpose.

@KostyaSha KostyaSha left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolve @jglick comments

@er1c

er1c commented Mar 1, 2019

Copy link
Copy Markdown
Contributor

I just ran into this issue, are there still outstanding issues I could help with to get it merged?

@er1c

er1c commented Mar 1, 2019

Copy link
Copy Markdown
Contributor

I have a unit test written for this, but I'm getting a bunch of unrelated errors doing mvn test:

shouldNotAllowSSRFUsingHookUrl(org.jenkinsci.plugins.github.config.GitHubPluginConfigTest)  Time elapsed: 0.159 sec  <<< ERROR!
org.jvnet.hudson.reactor.ReactorException: java.lang.Error: java.lang.reflect.InvocationTargetException
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.NullPointerException

I made sure I'm running java8, what's the proper procedure here?

Thanks,

Eric

@jglick

jglick commented Mar 1, 2019

Copy link
Copy Markdown
Member

I do not get such an error. Hard to guess at the cause without seeing the stack trace of the NullPointerException.

@er1c

er1c commented Mar 2, 2019

Copy link
Copy Markdown
Contributor

It looks like these tests are already marked as "existing failures" on the master branch: https://ci.jenkins.io/blue/organizations/jenkins/Plugins%2Fgithub-plugin/detail/PR-208/1/tests, so the CI is having issues too

@er1c

er1c commented Mar 2, 2019

Copy link
Copy Markdown
Contributor

Here is the full (example) error I get: https://gist.github.com/er1c/9713ccac7e6b6ece4516b9dac9f9e20a . I tried on both my OSX and a linux box, same result.

I just checked out master and it does not have this error, so let me see if I can figure out what in this PR broke the build.

@jetersen

jetersen commented Mar 2, 2019

Copy link
Copy Markdown
Member

BTW I strongly recommend inclusion of a functional test in PRs like this. There are several examples to look at of plugins which have a test dep on configuration-as-code for this purpose.

This might not be as easy as suggested. JCasC requires that the plugin targets Java 8 and at least 2.60.3 Jenkins core version 😢

Unless you are fine with bumping those values.

Some quick number crunching on http://stats.jenkins.io/pluginversions/github.html

92.88% are above 2.60 who have this plugin installed

@er1c

er1c commented Mar 2, 2019

Copy link
Copy Markdown
Contributor

I'm going to submit a separate PR that upgrades github-plugin to jekins.version 2.60.3 & java8. I have it compiling, and most of the tests successful, just working through other code changes that would be required for the updated dependencies. That should unblock this PR to include a JCasC test.

@er1c

er1c commented Apr 21, 2019

Copy link
Copy Markdown
Contributor

I would suggest closing this PR and referencing: #210 for ongoing tracking.

@dgarzon dgarzon closed this Apr 23, 2019
@dgarzon
dgarzon deleted the HOTFIX-add-casc-support branch April 23, 2019 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants