本文整理汇总了Java中jenkins.model.Jenkins.getItemByFullName方法的典型用法代码示例。如果您正苦于以下问题:Java Jenkins.getItemByFullName方法的具体用法?Java Jenkins.getItemByFullName怎么用?Java Jenkins.getItemByFullName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jenkins.model.Jenkins
的用法示例。
在下文中一共展示了Jenkins.getItemByFullName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: find
import jenkins.model.Jenkins; //导入方法依赖的package包/类
/**
* Search in Jenkins for a item with type T based on the job name
* @param jobName job to find, for jobs inside a folder use : {@literal <folder>/<folder>/<jobName>}
* @return the Job matching the given name, or {@code null} when not found
*/
static <T extends Item> T find(String jobName, Class<T> type) {
Jenkins jenkins = Jenkins.getActiveInstance();
// direct search, can be used to find folder based items <folder>/<folder>/<jobName>
T item = jenkins.getItemByFullName(jobName, type);
if (item == null) {
// not found in a direct search, search in all items since the item might be in a folder but given without folder structure
// (to keep it backwards compatible)
for (T allItem : jenkins.getAllItems(type)) {
if (allItem.getName().equals(jobName)) {
item = allItem;
break;
}
}
}
return item;
}