Silly question: How can I make a Credentials Select optional? I've tried the optional block, to no avail. Right now, I just left this on my Model as a Kludge:
config.jelly:
<f:section title="AWS Credentials and Region">
<f:entry title="${%Credentials}" field="credentialsId">
<c:select expressionAllowed="true"/>
</f:entry>
<f:entry title="AWS Region" field="awsRegion">
<f:textbox default="us-east-1"/>
</f:entry>
<!-- Not yet
<f:validateButton method="validateCredentials" title="Validate Credentials" with="credentialsId,awsRegion"/>
-->
</f:section>
and on the Descriptor:
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item owner) {
if (owner == null || !owner.hasPermission(Item.CONFIGURE)) {
return new ListBoxModel();
}
// when configuring the job, you only want those credentials that are available to ACL.SYSTEM selectable
// as we cannot select from a user's credentials unless they are the only user submitting the build
// (which we cannot assume) thus ACL.SYSTEM is correct here.
List<IdCredentials> credentials = new ArrayList<>();
credentials.add(new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "NONE", "None", "", ""));
credentials.addAll(CredentialsProvider.lookupCredentials(AmazonWebServicesCredentials.class, owner, ACL.SYSTEM, Collections.<DomainRequirement>emptyList()));
return new Model().withAll(credentials);
}
Works, but... Ugly.
Any ideas?