本文整理匯總了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;
}