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

280 Views Asked by At

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.

1

There are 1 best solutions below

0
Dinnerspy On BEST ANSWER

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);
        }