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?
--
-- Aldrin Leal, <[email protected]> / http://about.me/aldrinleal

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CALpo8NvOUwhiQbxAQsUBwNfpaSsGmambjgt8MDcvvFPgR7U9%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to