Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 4 additions & 3 deletions src/main/java/hudson/tasks/Ant.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ public AntInstallation(String name, String home, List<? extends ToolProperty<?>>
* @deprecated as of 1.308
* Use {@link #AntInstallation(String, String, List)}
*/
@Deprecated
public AntInstallation(String name, String home) {
this(name,home,Collections.<ToolProperty<?>>emptyList());
}
Expand Down Expand Up @@ -451,12 +452,12 @@ public String getDisplayName() {
// for compatibility reasons, the persistence is done by Ant.DescriptorImpl
@Override
public AntInstallation[] getInstallations() {
return Jenkins.getInstance().getDescriptorByType(Ant.DescriptorImpl.class).getInstallations();
return Jenkins.get().getDescriptorByType(Ant.DescriptorImpl.class).getInstallations();
}

@Override
public void setInstallations(AntInstallation... installations) {
Jenkins.getInstance().getDescriptorByType(Ant.DescriptorImpl.class).setInstallations(installations);
Jenkins.get().getDescriptorByType(Ant.DescriptorImpl.class).setInstallations(installations);
}

@Override
Expand All @@ -469,7 +470,7 @@ public List<? extends ToolInstaller> getDefaultInstallers() {
*/
public FormValidation doCheckHome(@QueryParameter File value) {
// this can be used to check the existence of a file on the server, so needs to be protected
if(!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER))
if(!Jenkins.get().hasPermission(Jenkins.ADMINISTER))
return FormValidation.ok();

if(value.getPath().equals(""))
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/tasks/AntWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public void setJdk(String jdk) {
@Override
public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener, EnvVars initialEnvironment) throws IOException, InterruptedException {
if (installation != null) {
toolEnv(context, installation, Jenkins.getActiveInstance().getDescriptorByType(Ant.DescriptorImpl.class).getInstallations(), workspace, listener, initialEnvironment);
toolEnv(context, installation, Jenkins.get().getDescriptorByType(Ant.DescriptorImpl.class).getInstallations(), workspace, listener, initialEnvironment);
Copy link
Member

Choose a reason for hiding this comment

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

\o/

}
if (jdk != null) {
toolEnv(context, jdk, Jenkins.getActiveInstance().getDescriptorByType(JDK.DescriptorImpl.class).getInstallations(), workspace, listener, initialEnvironment);
toolEnv(context, jdk, Jenkins.get().getDescriptorByType(JDK.DescriptorImpl.class).getInstallations(), workspace, listener, initialEnvironment);
}
}

Expand Down
54 changes: 0 additions & 54 deletions src/main/resources/hudson/tasks/Ant/config.groovy

This file was deleted.

55 changes: 55 additions & 0 deletions src/main/resources/hudson/tasks/Ant/config.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
Copyright (c) 2011, CloudBees, Inc.
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:f="/lib/form">
<j:if test="${size(descriptor.installations) != 0}">
Copy link
Member

Choose a reason for hiding this comment

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

You tested this logic interactively, right? (Cannot recall if there is a functional test for it.)

Copy link
Member

Choose a reason for hiding this comment

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

(There are actually good reasons to discards the if block and show this dropdown unconditionally, but that would be out of scope for this PR.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You tested this logic interactively, right?

I tested with and without installations but not sure to have cover all other potential cases there.

<f:entry title="${%Ant Version}">
<select class="setting-input" name="ant.antName">
<option value="(Default)">${%Default}</option>
<j:forEach var="install" items="${descriptor.installations}">
<f:option selected="${install.name == instance.ant.name}" value="${install.name}">
Copy link
Member

Choose a reason for hiding this comment

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

BTW we ought to have a standard control in core for selecting a tool installation.

${install.name}
</f:option>
</j:forEach>
</select>
</f:entry>
</j:if>

<f:entry title="${%Targets}" field="targets">
<f:expandableTextbox />
</f:entry>

<f:advanced>
<f:entry title="${%Build File}" field="buildFile">
<f:expandableTextbox />
</f:entry>
<f:entry title="${%Properties}" field="properties">
<f:expandableTextbox />
</f:entry>
<f:entry title="${%Java Options}" field="antOpts">
<f:expandableTextbox />
</f:entry>
</f:advanced>
</j:jelly>
53 changes: 0 additions & 53 deletions src/main/resources/hudson/tasks/AntWrapper/config.groovy

This file was deleted.

54 changes: 54 additions & 0 deletions src/main/resources/hudson/tasks/AntWrapper/config.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License

Copyright (c) 2016-2018, CloudBees, Inc.

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:f="/lib/form">
<j:set var="antInstallations" value="${app.getDescriptor('hudson.tasks.Ant').installations}" />
<j:if test="${size(antInstallations) != 0}">
<f:entry title="${%Ant Version}">
<select class="setting-input" name="ant.installation">
<option value="">${%Default}</option>
<j:forEach var="install" items="${antInstallations}">
<f:option selected="${install.name == instance.installation}" value="${install.name}">
${install.name}
</f:option>
</j:forEach>
</select>
</f:entry>
</j:if>

<j:set var="jdkInstallations" value="${app.getDescriptor('hudson.model.JDK').installations}" />
<j:if test="${size(jdkInstallations) != 0}">
<f:entry title="${%JDK}">
<select class="setting-input" name="ant.jdk">
<option value="">${%Default}</option>
<j:forEach var="install" items="${jdkInstallations}">
<f:option selected="${install.name == instance.jdk}" value="${install.name}">
${install.name}
</f:option>
</j:forEach>
</select>
</f:entry>
</j:if>
</j:jelly>
12 changes: 3 additions & 9 deletions src/test/java/hudson/tasks/AntTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ public void testConfigRoundtrip() throws Exception {
*/
@Test
public void testGlobalConfigAjax() throws Exception {
HtmlPage p = Jenkins.getVersion().toString().startsWith("2") ?
r.createWebClient().goTo("configureTools") :
r.createWebClient().goTo("configure");
HtmlPage p = r.createWebClient().goTo("configureTools");
HtmlForm f = p.getFormByName("config");
HtmlButton b = r.getButtonByCaption(f, "Add Ant");
b.click();
Expand Down Expand Up @@ -184,12 +182,8 @@ public void testSensitiveParameters() throws Exception {
project.getBuildersList().add(new Ant("foo",null,null,null,null));

FreeStyleBuild build = project.scheduleBuild2(0).get();
// Due to bug JENKINS-28790. Password should not be shown but it is.
if (SystemUtils.IS_OS_WINDOWS && Jenkins.getVersion().isOlderThan(new VersionNumber("1.653"))) {
r.assertLogContains("-Dpassword=12345", build);
} else {
r.assertLogNotContains("-Dpassword=12345", build);
}

r.assertLogNotContains("-Dpassword=12345", build);
}

@Test
Expand Down