Skip to content

Commit

Permalink
Move proxy configuration form out of pluginManager screens as it is n…
Browse files Browse the repository at this point in the history
…ot related (#8693)

* Move proxy configuration form out of pluginManager screens as it is not related

---------

Signed-off-by: Olivier Lamy <[email protected]>
  • Loading branch information
olamy authored Dec 4, 2023
1 parent 932cb22 commit 1e9372e
Show file tree
Hide file tree
Showing 18 changed files with 141 additions and 44 deletions.
8 changes: 1 addition & 7 deletions core/src/main/java/hudson/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1803,13 +1803,7 @@ public HttpResponse doProxyConfigure(StaplerRequest req) throws IOException, Ser
jenkins.checkPermission(Jenkins.ADMINISTER);

ProxyConfiguration pc = req.bindJSON(ProxyConfiguration.class, req.getSubmittedForm());
if (pc.name == null) {
jenkins.proxy = null;
ProxyConfiguration.getXmlFile().delete();
} else {
jenkins.proxy = pc;
jenkins.proxy.save();
}
ProxyConfigurationManager.saveProxyConfiguration(pc);

Check warning on line 1806 in core/src/main/java/hudson/PluginManager.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 1806 is not covered by tests
return new HttpRedirect("advanced");
}

Expand Down
72 changes: 72 additions & 0 deletions core/src/main/java/hudson/ProxyConfigurationManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* The MIT License
*
* Copyright (c) 2023, CloudBees Inc, and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package hudson;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.model.Descriptor;
import java.io.IOException;
import jenkins.model.GlobalConfiguration;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.StaplerRequest;

@Extension @Restricted(NoExternalUse.class)
public class ProxyConfigurationManager extends GlobalConfiguration {

@NonNull
@Override
public String getDisplayName() {
return Messages.ProxyConfigurationManager_DisplayName();
}

public Descriptor<ProxyConfiguration> getProxyDescriptor() {
return Jenkins.get().getDescriptor(ProxyConfiguration.class);
}

@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
ProxyConfiguration pc = req.bindJSON(ProxyConfiguration.class, json);
try {
saveProxyConfiguration(pc);
} catch (IOException e) {
throw new FormException(e.getMessage(), e, null);

Check warning on line 56 in core/src/main/java/hudson/ProxyConfigurationManager.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 55-56 are not covered by tests
}
return true;
}

public static void saveProxyConfiguration(ProxyConfiguration pc) throws IOException {
Jenkins jenkins = Jenkins.get();
if (pc.name == null) {

Check warning on line 63 in core/src/main/java/hudson/ProxyConfigurationManager.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 63 is only partially covered, one branch is missing
jenkins.proxy = null;
ProxyConfiguration.getXmlFile().delete();
} else {
jenkins.proxy = pc;
jenkins.proxy.save();

Check warning on line 68 in core/src/main/java/hudson/ProxyConfigurationManager.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 67-68 are not covered by tests
}
}

}
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 @@ -127,3 +127,5 @@ PluginWrapper.NoSuchPlugin=No such plugin found with the name ''{0}''
PluginWrapper.Error.Disabling=There was an error disabling the ''{0}'' plugin. Error: ''{1}''
TcpSlaveAgentListener.PingAgentProtocol.displayName=Ping protocol

ProxyConfigurationManager.DisplayName=Proxy Configuration
ProxyConfigurationManager.Description=Configure the http proxy used by Jenkins
19 changes: 4 additions & 15 deletions core/src/main/resources/hudson/PluginManager/advanced.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,11 @@ THE SOFTWARE.
<l:main-panel>
<l:app-bar title="${%Advanced settings}"/>

<div class="alert alert-info">
<strong>${%proxyMovedBlurb(rootURL+"/manage/configure")}</strong>
</div>

<div class="jenkins-form">
<section class="jenkins-section jenkins-!-margin-bottom-5">
<h2 class="jenkins-section__title">${%HTTP Proxy Configuration}</h2>
<f:form method="post" action="proxyConfigure" name="proxyConfigure">
<j:scope>
<j:set var="instance" value="${app.proxy}"/>
<j:set var="descriptor" value="${it.proxyDescriptor}"/>
<st:include from="${descriptor}" page="${descriptor.configPage}"/>
</j:scope>
<l:isAdmin>
<f:block>
<f:submit/>
</f:block>
</l:isAdmin>
</f:form>
</section>

<l:isAdmin>
<section class="jenkins-section jenkins-!-margin-bottom-5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@
deploytext=\
You can select a plugin file from your local system or provide a URL to install \
a plugin from outside the configured update site(s).

proxyMovedBlurb=The Proxy configuration form has been moved to <a href="{0}">Configure System page</a>
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ Server=Serveur
User\ name=Nom d''utilisateur
No\ Proxy\ Host=Pas de proxy pour
Password=Mot de passe
proxyMovedBlurb=La configuration du Proxy a été déplacé ici <a href="{0}">Page du configuration du System</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
The MIT License
Copyright (c) 2023, CloudBees Inc, and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:section title="${%HTTP Proxy Configuration}">
<f:advanced title="${%Setup}">
<j:scope>
<j:set var="descriptor" value="${instance.getProxyDescriptor()}"/>
<j:set var="instance" value="${app.proxy}"/>
<st:include from="${descriptor}" page="${descriptor.configPage}"/>
</j:scope>
</f:advanced>
</f:section>
</j:jelly>
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ UpdateCenter.Status.CheckingJavaNet=Checking update center connectivity
UpdateCenter.Status.Success=Success
UpdateCenter.Status.UnknownHostException=\
<span class=error>Failed to resolve host name {0}. \
Perhaps you need to <a href="{1}manage/pluginManager/advanced">configure HTTP proxy?</a></span>
Perhaps you need to <a href="{1}manage/configure">configure HTTP proxy?</a></span>
UpdateCenter.Status.ConnectionFailed=\
<span class=error>Failed to connect to {0}. \
Perhaps you need to <a href="{1}manage/pluginManager/advanced">configure HTTP proxy?</a></span>
Perhaps you need to <a href="{1}manage/configure">configure HTTP proxy?</a></span>
UpdateCenter.init=Initialing update center
UpdateCenter.CoreUpdateMonitor.DisplayName=Jenkins Update Notification

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages_bg.properties
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,10 @@ UpdateCenter.Status.Success=\
Успех
UpdateCenter.Status.UnknownHostException=\
<span class=error>Неуспешна проверка на адреса „{0}“.\
Вероятно трябва да <a href="{1}manage/pluginManager/advanced">настроите\
Вероятно трябва да <a href="{1}manage/configure">настроите\
сървър-посредник за HTTP</a>.</span>
UpdateCenter.Status.ConnectionFailed=\
Вероятно трябва да <a href="{1}manage/pluginManager/advanced">настроите\
Вероятно трябва да <a href="{1}manage/configure">настроите\
сървър-посредник за HTTP</a>.</span>
UpdateCenter.init=\
Инициализиране на центъра за обновяване
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ UpdateCenter.Status.CheckingJavaNet=Überprüfe Zugang zu jenkins-ci.org-Server
UpdateCenter.Status.Success=Erfolgreich
UpdateCenter.Status.UnknownHostException=\
<span class=error>Hostname {0} konnte nicht aufgelöst werden. \
Eventuell sollten Sie einen <a href="{1}manage/pluginManager/advanced">HTTP-Proxy konfigurieren</a>?</span>
Eventuell sollten Sie einen <a href="{1}manage/configure">HTTP-Proxy konfigurieren</a>?</span>
UpdateCenter.Status.ConnectionFailed=\
<span class=error>Es konnte keine Verbindung zu {0} aufgebaut werden. \
Eventuell sollten Sie einen <a href="{1}manage/pluginManager/advanced">HTTP-Proxy konfigurieren</a>?</span>
Eventuell sollten Sie einen <a href="{1}manage/configure">HTTP-Proxy konfigurieren</a>?</span>
UpdateCenter.init=Initialisiere das Update Center
UpdateCenter.CoreUpdateMonitor.DisplayName=Jenkins-Update-Benachrichtigungen
UpdateCenter.DisplayName=Update-Center
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ UpdateCenter.Status.CheckingJavaNet=Probando conectividad con jenkins-ci.org
UpdateCenter.Status.Success=Correcto
UpdateCenter.Status.UnknownHostException=\
<span class=error>Nombre de servidor imposible de resolver {0}. \
Quizás tengas que configurar to <a href="{1}manage/pluginManager/advanced">proxy</a></span>
Quizás tengas que configurar to <a href="{1}manage/configure">proxy</a></span>
UpdateCenter.Status.ConnectionFailed=\
<span class=error>Imposible de conectar con {0}. \
Quizás tengas que configurar to <a href="{1}manage/pluginManager/advanced">proxy</a></span>
Quizás tengas que configurar to <a href="{1}manage/configure">proxy</a></span>
UpdateCenter.init=Inicializando centro de actualizaciones
UpdateCenter.PluginCategory.builder=Plugins relacionados con la forma de ejecutar trabajos
UpdateCenter.PluginCategory.buildwrapper=Plugins que añaden tareas relacionadas con la ejecución
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ UpdateCenter.Status.CheckingJavaNet=Vérification de la connexion à jenkins-ci.
UpdateCenter.Status.Success=Succès
UpdateCenter.Status.UnknownHostException=\
<span class=error>Impossible de résoudre le nom de host {0}. \
Peut-être devez-vous <a href="{1}manage/pluginManager/advanced">configurer un proxy HTTP?</a></span>
Peut-être devez-vous <a href="{1}manage/configure">configurer un proxy HTTP?</a></span>
UpdateCenter.Status.ConnectionFailed=\
<span class=error>Echec lors de la connexion à {0}. \
Peut-être devez-vous <a href="{1}manage/pluginManager/advanced">configurer le proxy HTTP.</a></span>
Peut-être devez-vous <a href="{1}manage/configure">configurer le proxy HTTP.</a></span>
UpdateCenter.init=Initialisation du centre de mise à jour
UpdateCenter.CoreUpdateMonitor.DisplayName=Notification de mise à jour de Jenkins

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,11 @@ UpdateCenter.Status.CheckingJavaNet=Controllo connettività al Centro \
aggiornamenti in corso
UpdateCenter.Status.ConnectionFailed=<span class=error>Impossibile \
connettersi a {0}. Forse è necessario \
<a href="{1}manage/pluginManager/advanced">configurare il proxy HTTP?</a></span>
<a href="{1}manage/configure">configurare il proxy HTTP?</a></span>
UpdateCenter.Status.Success=Operazione completata
UpdateCenter.Status.UnknownHostException=<span class=error>Impossibile \
risolvere il nome host {0}. Forse è necessario \
<a href="{1}manage/pluginManager/advanced">configurare il proxy HTTP?</a></span>
<a href="{1}manage/configure">configurare il proxy HTTP?</a></span>
User.IllegalFullname="{0}" è vietato come nome completo per motivi di sicurezza.
User.IllegalUsername="{0}" è vietato come nome utente per motivi di sicurezza.
View.ConfigurePermission.Description=Questo permesso consente agli utenti di \
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ UpdateCenter.Status.CheckingJavaNet=jenkins-ci.orgとの接続をチェックし
UpdateCenter.Status.Success=成功
UpdateCenter.Status.UnknownHostException=\
<span class=error>ホスト名 {0}の解決に失敗しました。 \
たぶん、<a href="{1}manage/pluginManager/advanced">HTTPプロクシーを設定</a>する必要があります。</span>
たぶん、<a href="{1}manage/configure">HTTPプロクシーを設定</a>する必要があります。</span>
UpdateCenter.Status.ConnectionFailed=\
<span class=error>{0} との接続に失敗しました。 \
たぶん、<a href="{1}manage/pluginManager/advanced">HTTPプロクシーを設定</a>する必要があります。</span>
たぶん、<a href="{1}manage/configure">HTTPプロクシーを設定</a>する必要があります。</span>
UpdateCenter.init=アップデートセンターの初期化中
UpdateCenter.PluginCategory.builder=ビルドツール
UpdateCenter.PluginCategory.buildwrapper=ビルドラッパー
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages_lt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ UpdateCenter.Status.CheckingJavaNet=Tikrinamas prisijungimas prie atnaujinimų c
UpdateCenter.Status.Success=Sėkmė
UpdateCenter.Status.UnknownHostException=\
<span class=error>Nepavyko išspręsti stoties pavadinimo {0}. \
Gal jums reikia <a href="{1}manage/pluginManager/advanced">sukonfigūruoti HTTP šliuzą?</a></span>
Gal jums reikia <a href="{1}manage/configure">sukonfigūruoti HTTP šliuzą?</a></span>
UpdateCenter.Status.ConnectionFailed=\
<span class=error>Nepavyko prisijungti prie {0}. \
Gal jums reikia <a href="{1}manage/pluginManager/advanced">sukonfigūruoti HTTP šliuzą?</a></span>
Gal jums reikia <a href="{1}manage/configure">sukonfigūruoti HTTP šliuzą?</a></span>
UpdateCenter.init=Inicializuojamas atnaujinimų centras
UpdateCenter.PluginCategory.android=Android kūrimas
UpdateCenter.PluginCategory.builder=Kūrimo įrankiai
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Slave.Remote.Director.Mandatory=Diretório remoto é obrigatório
Run.InProgressDuration={0} e contando
UpdateCenter.Status.UnknownHostException=\
<span class=error>Erro ao resolver o nome do hospedeiro {0}. \
Talvez você precise <a href="{1}manage/pluginManager/advanced">configurar um proxy HTTP?</a></span>
Talvez você precise <a href="{1}manage/configure">configurar um proxy HTTP?</a></span>
Hudson.NotUsesUTF8ToDecodeURL=não use caracteres UTF-8 nas URLs
UpdateCenter.Status.CheckingInternet=Checando conexão com a Internet
View.DeletePermission.Description=\
Expand Down Expand Up @@ -203,7 +203,7 @@ Hudson.NotANegativeNumber=Número não negativo
UpdateCenter.PluginCategory.misc=Diversos
UpdateCenter.Status.ConnectionFailed=\
<span class=error>Erro ao conectar em {0}. \
Talvez voê precise <a href="{1}manage/pluginManager/advanced">configurar um proxy HTTP?</a></span>
Talvez voê precise <a href="{1}manage/configure">configurar um proxy HTTP?</a></span>
UpdateCenter.PluginCategory.maven=Maven
UpdateCenter.PluginCategory.upload=Carregadores de artefatos
Permalink.LastUnstableBuild=Última construção instável
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages_sr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ UpdateCenter.Status.CheckingInternet=Провера везом са интерн
UpdateCenter.Status.CheckingJavaNet=Провера везом са центар за aжурирање
UpdateCenter.Status.Success=Успех
UpdateCenter.Status.UnknownHostException=<span class=error>Неуспешна провера адресе {0}. \
Можда морате <a href="{1}manage/pluginManager/advanced">поставити HTTP proxy?</a></span>
Можда морате <a href="{1}manage/configure">поставити HTTP proxy?</a></span>
UpdateCenter.Status.ConnectionFailed=<span class=error>Неуспешно повезивање са {0}. \
Можда морате <a href="{1}manage/pluginManager/advanced">поставити HTTP proxy?</a></span>
Можда морате <a href="{1}manage/configure">поставити HTTP proxy?</a></span>
UpdateCenter.init=Инициализација центра за ажурирање
UpdateCenter.PluginCategory.builder=Алати за изградњу
UpdateCenter.PluginCategory.buildwrapper=Скрипт омотачи за изградњу
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ UpdateCenter.Status.CheckingJavaNet=檢查是否能連到更新中心
UpdateCenter.Status.Success=成功
UpdateCenter.Status.UnknownHostException=\
<span class=error>無法解析主機名稱 {0}。\
說不定您應該要<a href="{1}manage/pluginManager/advanced">設定 HTTP 代理伺服器</a>?</span>
說不定您應該要<a href="{1}manage/configure">設定 HTTP 代理伺服器</a>?</span>
UpdateCenter.Status.ConnectionFailed=\
<span class=error>無法連線到{0}。\
說不定您應該要<a href="{1}manage/pluginManager/advanced">設定 HTTP 代理伺服器</a>?</span>
說不定您應該要<a href="{1}manage/configure">設定 HTTP 代理伺服器</a>?</span>
UpdateCenter.init=初始化更新中心
UpdateCenter.PluginCategory.builder=建置工具
UpdateCenter.PluginCategory.buildwrapper=建置包裝程式
Expand Down

0 comments on commit 1e9372e

Please sign in to comment.