Skip to content

[JENKINS-60738] Fix global configuration submission from UI - #347

Merged
KostyaSha merged 8 commits into
jenkinsci:masterfrom
Dohbedoh:JENKINS-60738
Nov 3, 2025
Merged

[JENKINS-60738] Fix global configuration submission from UI#347
KostyaSha merged 8 commits into
jenkinsci:masterfrom
Dohbedoh:JENKINS-60738

Conversation

@Dohbedoh

@Dohbedoh Dohbedoh commented May 2, 2023

Copy link
Copy Markdown
Contributor

Fixes JENKINS-60738 caused by changes introduced in #221.

Databinding of hookUrl is not working properly, per my understanding because the DataboundSetter setHookUrl(String hookUrl) accepts a String but the field is a URL. While adding a public void setHookUrl(URL hookUrl) might solve some of the problem, then there is yet another issue that disabling the Specify another hook URL for GitHub configuration checkbox does not remove the hook URL at all... that seems wrong.

So the propose fix:

  • handle the binding and the optional property state in the configure(StaplerRequest req, JSONObject json)
  • reactivate and adjusted the global configuration UI tests
  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@julieheard julieheard left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, manually tested and is working 🙂

@jglick

jglick commented May 3, 2023

Copy link
Copy Markdown
Member

While this sounds fine as a hotfix, the proper fix would be to delete all the overrides and special cases handling and fix the form to use normal databinding by convention.

Comment on lines 27 to 37
f.entry(title: _("Override Hook URL")) {
g.blockWrapper {
f.optionalBlock(title: _("Specify another hook URL for GitHub configuration"),
name: "isOverrideHookUrl",
inline: true,
checked: instance.isOverrideHookUrl()) {
f.entry(field: "hookUrl") {
f.textbox(checkMethod: "post")
f.textbox(checkMethod: "post", name: "hookUrl")
}
}
}

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.

For example all of this should just be like

<f:entry field="hookUrl">
  <f:textbox label="Alternate hook URL for GitHub configuration"/>
</f:entry>

which may be blank.

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.

Oh I see. Remove all the optional block that is not necessary.. Yeah sounds good to me I can test this.

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.

Would be more work for sure. The usual problem with this sort of fix is retaining compatibility for both XML settings and JCasC. Sometimes hacking up the JSON processing in the GUI logic is the only option since refactoring to a simpler structure would break something.

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.

the thing that bother me is the type URL of the hookUrl... Because of that type, the value cannot actually be blank :( :

java.net.MalformedURLException: no protocol: 
	at java.base/java.net.URL.<init>(URL.java:645)
	at java.base/java.net.URL.<init>(URL.java:541)
	at java.base/java.net.URL.<init>(URL.java:488)
	at org.kohsuke.stapler.Stapler$3.convert(Stapler.java:1141)
Caused: org.apache.commons.beanutils.ConversionException: no protocol: 

So it is not that simple to "reset" the hook URL because of the binding.. I thought about changing the type from URL to String but the existing public getter might be a problem: https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github/config/GitHubPluginConfig.java#L131-L141

Changing its signature could be a breaking change. Though it does not seem to be used outside the scope of that plugin repo: https://github.com/search?ref=simplesearch&type=code&q=user%3Ajenkinsci++getHookUrl.

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.

BTW use permalinks for better display:

/**
* @return hook url used as endpoint to search and write auto-managed hooks in GH
* @throws GHPluginConfigException if default jenkins url is malformed
*/
public URL getHookUrl() throws GHPluginConfigException {
if (hookUrl != null) {
return hookUrl;
} else {
return constructDefaultUrl();
}
}

@jtnord

jtnord commented Jun 13, 2023

Copy link
Copy Markdown
Member

@KostyaSha are you ok with this as the active maintainer of this plugin?

@jrtc27

jrtc27 commented Mar 5, 2024

Copy link
Copy Markdown

What's the status of this? I've just run into this with our own instance.

@yahooguntu

Copy link
Copy Markdown

I have the same issue; as a workaround I've been adding <hookUrl> directly to github-plugin-configuration.xml, but unfortunately it's cleared out when I save/apply System settings in the web UI.

@jrtc27

jrtc27 commented Mar 6, 2024

Copy link
Copy Markdown

I have the same issue; as a workaround I've been adding <hookUrl> directly to github-plugin-configuration.xml, but unfortunately it's cleared out when I save/apply System settings in the web UI.

If you edit the config file and restart so it has the updated value in memory then the UI should show the correct setting and not clobber it on save.

@franknarf8

Copy link
Copy Markdown

Can this be merged soon? I've just noticed this open PR after implementing the same fix and opening another PR : #375

Feel free to close the other PR

@KostyaSha @jglick

@jglick

jglick commented Apr 30, 2024

Copy link
Copy Markdown
Member

(I am not a maintainer)

@Dohbedoh

Copy link
Copy Markdown
Contributor Author

@jenkinsci/github-plugin-developers anybody able to merge this ?

@Dohbedoh
Dohbedoh requested a review from a team as a code owner November 1, 2024 01:54
@jglick

jglick commented Nov 1, 2024

Copy link
Copy Markdown
Member

@KostyaSha perhaps

@Dohbedoh
Dohbedoh requested a review from KostyaSha November 15, 2024 00:23
@Dohbedoh

Dohbedoh commented Jan 8, 2025

Copy link
Copy Markdown
Contributor Author

@KostyaSha @lanwen @oleg-nenashev anybody able to help merge this ?

@sebastianreloaded

Copy link
Copy Markdown

I have the same issue; as a workaround I've been adding <hookUrl> directly to github-plugin-configuration.xml, but unfortunately it's cleared out when I save/apply System settings in the web UI.

If you edit the config file and restart so it has the updated value in memory then the UI should show the correct setting and not clobber it on save.

But even when adding the hookUrl to the xml and restarting, the endpoint still only works for "/github-webhook/". everything else gives a "HTTP ERROR 403 No valid crumb was included in the request"

@jgarciacloudbees

Copy link
Copy Markdown

Hi @jenkinsci/github-plugin-developers, is there any chance to merge this PR?

@jtnord

jtnord commented Nov 3, 2025

Copy link
Copy Markdown
Member

Hi @jenkinsci/github-plugin-developers, is there any chance to merge this PR?

the group contains 4 3 users (and a bot) who are not so active, I would suggest you start the process to adopt this plugin.

@KostyaSha

Copy link
Copy Markdown
Member

the group contains 4 3 users (and a bot) who are not so active, I would suggest you start the process to adopt this plugin.

thanks to dependabot who spamed from all jenkins repos

@KostyaSha
KostyaSha merged commit daa1fa7 into jenkinsci:master Nov 3, 2025
@olamy

olamy commented Feb 11, 2026

Copy link
Copy Markdown
Member

@KostyaSha thanks for merging. Could you please make a release now? Thanks

@olamy

olamy commented Feb 11, 2026

Copy link
Copy Markdown
Member

Hi @jenkinsci/github-plugin-developers, is there any chance to merge this PR?

the group contains 4 3 users (and a bot) who are not so active, I would suggest you start the process to adopt this plugin.

looks like a good idea.

@KostyaSha let us know if you are too busy to maintain the plugin actively, I'm pretty sure some people will be happy to help to maintain such critical plugin.

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.