Skip to content

Commit

Permalink
[JENKINS-36544] Fix Node Properties on Jenkins 2.205+ (#440)
Browse files Browse the repository at this point in the history
* [JENKINS-36544] Fix Node Properties on Jenkins 2.205+

This is a follow-up fix for PR #382.

In 2.204, the "Configure Clouds" screen was on the main /configure system
configuration page. As a result, `${it}` referred to the global system
object, aka the Hudson instance.

In 2.205, PR jenkinsci/jenkins#4339 merged, which moves the Configure Clouds
section to a new page: /configureClouds. As a result of that change, `${it}`
no longer refers to the Hudson instance, but to a new
GlobalCloudConfiguration object. That object does not have the
`getNodePropertyDescriptors()` method, so it is not able to populate the
"Node Properties" block.

Switching that to `${app}` gives it a correct reference to the Hudson object,
and that allows it to show the Node Properties block on all Jenkins versions,
both before and after v2.205.

* Use the correct form of getNodePropertyDescriptors()

Current master is calling `${it.getNodePropertyDescriptors()}`, but on
Jenkins versions <= 2.204, that is calling the method on the global Jenkins
node (via Node class).

It should instead be using the version of the method that was added in
SlaveTemplate, and to do that from a Jelly script, it needs to be moved into
the SlaveTemplate.DescriptorImpl class.
  • Loading branch information
jhansche authored Mar 16, 2020
1 parent c2f4b5c commit f1714da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/main/java/hudson/plugins/ec2/SlaveTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,6 @@ public int getMaxTotalUses() {
return maxTotalUses;
}

public List<NodePropertyDescriptor> getNodePropertyDescriptors() {
return NodePropertyDescriptor.for_(NodeProperty.all(), EC2AbstractSlave.class);
}

public DescribableList<NodeProperty<?>, NodePropertyDescriptor> getNodeProperties() {
return Objects.requireNonNull(nodeProperties);
}
Expand Down Expand Up @@ -1798,6 +1794,10 @@ public String getDefaultConnectionStrategy() {
return ConnectionStrategy.PRIVATE_IP.toString();
}

public List<NodePropertyDescriptor> getNodePropertyDescriptors() {
return NodePropertyDescriptor.for_(NodeProperty.all(), EC2AbstractSlave.class);
}

public ListBoxModel doFillConnectionStrategyItems(@QueryParameter String connectionStrategy) {
return Stream.of(ConnectionStrategy.values())
.map(v -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ THE SOFTWARE.
<f:textbox default="-1"/>
</f:entry>

<f:descriptorList title="${%Node Properties}" field="nodeProperties" descriptors="${it.getNodePropertyDescriptors()}" />
<f:descriptorList title="${%Node Properties}" field="nodeProperties" descriptors="${descriptor.nodePropertyDescriptors}" />

</f:advanced>

Expand Down

0 comments on commit f1714da

Please sign in to comment.