javajenkins-pluginscredentialsjelly

How do i add drop down field for credentials in the plugin im devloping


I am some what new to extending Jenkins and was wondering how would i generate the code for adding a credentials drop down like the one in this picture.
(source: jenkins.io)

I have looked at some examples and noted they used this jelly code

<f:entry title="${%Credentials}" field="credentialsId">
  <c:select/>
</f:entry>

But when i implement this my Credentials line in the build job settings dose not contain the drop down.


Solution

  • Note figured it out. Posting answer for others benefit. In order to dynamically fill the list you must create a doFillCredentialsIdItems like the method bellow along with adding a import to the credentials plugin.

    public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String credentialsId) {
            StandardListBoxModel result = new StandardListBoxModel();
                            return result
                    .includeEmptyValue()
                    .includeAs(ACL.SYSTEM, Jenkins.get(),
                     UsernamePasswordCredentialsImpl.class)
                    .includeCurrentValue(credentialsId);
            }