java - 如何在我正在开发的插件中添加凭据的下拉字段
问题描述
我对扩展 Jenkins 有点陌生,我想知道如何生成代码来添加凭据下拉菜单,就像这张图片中的那样。 我看过一些例子并注意到他们使用了这个果冻代码
<f:entry title="${%Credentials}" field="credentialsId">
<c:select/>
</f:entry>
但是当我在构建作业设置中实现这个我的凭据行时不包含下拉菜单。
解决方案
笔记想通了。为他人利益发布答案。为了动态填充列表,您必须像下面的方法一样创建一个 doFillCredentialsIdItems,并将导入添加到凭证插件。
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);
}
推荐阅读
- python - 我应该删除计算机上的所有 python 包吗
- google-apps-script - 谷歌表格单元格重新计算
- tomcat - 使用 Azure ADFS 的 tomcat 托管 Web 应用的 SSO
- f# - F# ConsoleKeyInfo 类型不匹配
- android - Android Studio 3.2 不生成签名包/apk
- python - 无法在原子编辑器上添加数据原子包
- ios - 为什么这个线程不执行最后一行代码
- windows - windows如何处理未注册的windows?
- odata - 如何在 Odata V4 远程服务中进行身份验证
- java - 为什么不能使用spring AOP更改响应类型,除了返回对象