Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-69032] Plugin manager update site URL can be saved empty #6886

Merged
merged 15 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/src/main/java/hudson/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,20 @@ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, Servl
return FormValidation.ok();
}

@Restricted(NoExternalUse.class)
@RequirePOST public FormValidation doCheckUpdateSiteUrl(StaplerRequest request, @QueryParameter String value) throws IOException {
if (StringUtils.isNotBlank(value)) {
try {
new URL(value);
NotMyFault marked this conversation as resolved.
Show resolved Hide resolved
return FormValidation.ok();
} catch (MalformedURLException e) {
return FormValidation.error(e.getMessage());
}
} else {
return FormValidation.error(Messages.PluginManager_emptyUpdateSiteUrl());
}
}

@Restricted(NoExternalUse.class)
@RequirePOST public HttpResponse doCheckUpdatesServer() throws IOException {
Jenkins.get().checkPermission(Jenkins.SYSTEM_READ);
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/resources/hudson/Messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ PluginManager.insecureUrl=\
PluginManager.invalidUrl=\
You are using an invalid URL to download the plugin, only https and http (not recommended) are supported.

PluginManager.emptyUpdateSiteUrl=\
The update site cannot be empty. Please enter a valid url.

AboutJenkins.DisplayName=About Jenkins
AboutJenkins.Description=See the version and license information.
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/hudson/Messages_zh_TW.properties
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,4 @@ PluginWrapper.NoSuchPlugin=找不到名為「{0}」的外掛
PluginWrapper.Error.Disabling=停用外掛「{0}」時發生錯誤,錯誤\: 「{1}」
TcpSlaveAgentListener.PingAgentProtocol.displayName=Ping 協定

PluginManager.emptyUpdateSiteUrl=更新站台網址不得為空,請輸入網址
6 changes: 6 additions & 0 deletions core/src/main/resources/hudson/PluginManager/_updateSite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
document.getElementById("reset-to-default").onclick = function (event) {
event.preventDefault();
const siteUrlInput = document.getElementById("update-site-url");
siteUrlInput.value = "https://updates.jenkins.io/current/update-center.json";
NotMyFault marked this conversation as resolved.
Show resolved Hide resolved
siteUrlInput.dispatchEvent(new Event('change'));
}
8 changes: 6 additions & 2 deletions core/src/main/resources/hudson/PluginManager/advanced.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,13 @@ THE SOFTWARE.
<h2 class="jenkins-section__title">${%Update Site}</h2>
<f:form method="post" action="siteConfigure" name="siteConfigure">
<f:entry title="${%URL}">
<f:textbox name="site"
value="${app.updateCenter.getSite(app.updateCenter.ID_DEFAULT).url}"/>
<a id="reset-to-default" href="#">${%Reset to default}</a>
<f:textbox name="site"
id="update-site-url"
value="${app.updateCenter.getSite(app.updateCenter.ID_DEFAULT).url}"
checkUrl="'checkUpdateSiteUrl?value='+this.value"/>
benebsiny marked this conversation as resolved.
Show resolved Hide resolved
</f:entry>
<st:adjunct includes="hudson.PluginManager._updateSite"/>
<l:isAdmin>
<f:block>
<f:submit/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ Deploy\ Plugin=部署外掛
Deploy=部署
Advanced\ Settings=進階設定
Or=或
Reset\ to\ default=重設回預設值