本文整理汇总了Java中hudson.model.Item类的典型用法代码示例。如果您正苦于以下问题:Java Item类的具体用法?Java Item怎么用?Java Item使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Item类属于hudson.model包,在下文中一共展示了Item类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChange
import hudson.model.Item; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void onChange(Saveable o, XmlFile file) {
if (!(o instanceof Item)) {
// must be an Item
return;
}
SCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem((Item) o);
if (item == null) {
// more specifically must be an SCMTriggerItem
return;
}
SCMTrigger trigger = item.getSCMTrigger();
if (trigger == null || trigger.isIgnorePostCommitHooks()) {
// must have the trigger enabled and not opted out of post commit hooks
return;
}
for (SCM scm : item.getSCMs()) {
if (scm instanceof GitSCM) {
// we have a winner
GiteaWebhookListener.register(item, (GitSCM) scm);
}
}
}
示例2: doFillMirrorgateCredentialsIdItems
import hudson.model.Item; //导入依赖的package包/类
public ListBoxModel doFillMirrorgateCredentialsIdItems(
@AncestorInPath Item item,
@QueryParameter("mirrorgateCredentialsId") String credentialsId) {
StandardListBoxModel result = new StandardListBoxModel();
if (item == null) {
if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
return result.includeCurrentValue(credentialsId);
}
} else if (!item.hasPermission(Item.EXTENDED_READ)
&& !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return result.includeCurrentValue(credentialsId);
}
return result
.includeEmptyValue()
.includeAs(ACL.SYSTEM, item, StandardUsernamePasswordCredentials.class);
}
示例3: doCheckMirrorgateCredentialsId
import hudson.model.Item; //导入依赖的package包/类
public FormValidation doCheckMirrorgateCredentialsId(
@AncestorInPath Item item,
@QueryParameter("mirrorgateCredentialsId") String credentialsId) {
if (item == null) {
if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
return FormValidation.ok();
}
} else if (!item.hasPermission(Item.EXTENDED_READ)
&& !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return FormValidation.ok();
}
if (StringUtils.isBlank(credentialsId)) {
return FormValidation.ok();
}
if (credentialsId.startsWith("${") && credentialsId.endsWith("}")) {
return FormValidation.warning(
"Cannot validate expression based credentials");
}
return FormValidation.ok();
}
示例4: doIndex
import hudson.model.Item; //导入依赖的package包/类
@SuppressWarnings("unused")
public void doIndex() throws IOException {
HttpServletRequest req = Stapler.getCurrentRequest();
GerritProjectEvent projectEvent = getBody(req);
log.info("GerritWebHook invoked for event " + projectEvent);
List<Item> jenkinsItems = Jenkins.getActiveInstance().getAllItems();
for (Item item : jenkinsItems) {
if (item instanceof SCMSourceOwner) {
SCMSourceOwner scmJob = (SCMSourceOwner) item;
log.info("Found SCM job " + scmJob);
List<SCMSource> scmSources = scmJob.getSCMSources();
for (SCMSource scmSource : scmSources) {
if (scmSource instanceof GerritSCMSource) {
GerritSCMSource gerritSCMSource = (GerritSCMSource) scmSource;
if (projectEvent.matches(gerritSCMSource.getRemote())) {
log.info(
"Triggering SCM event for source " + scmSources.get(0) + " on job " + scmJob);
scmJob.onSCMSourceUpdated(scmSource);
}
}
}
}
}
}
示例5: doFillCredentialsIdItems
import hudson.model.Item; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(
@AncestorInPath Item context,
@QueryParameter String remote,
@QueryParameter String credentialsId) {
if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)
|| context != null && !context.hasPermission(Item.EXTENDED_READ)) {
return new StandardListBoxModel().includeCurrentValue(credentialsId);
}
return new StandardListBoxModel()
.includeEmptyValue()
.includeMatchingAs(
context instanceof Queue.Task
? Tasks.getAuthenticationOf((Queue.Task) context)
: ACL.SYSTEM,
context,
StandardUsernameCredentials.class,
URIRequirementBuilder.fromUri(remote).build(),
GitClient.CREDENTIALS_MATCHER)
.includeCurrentValue(credentialsId);
}
示例6: doFillCheckoutCredentialsIdItems
import hudson.model.Item; //导入依赖的package包/类
@Restricted(NoExternalUse.class)
public ListBoxModel doFillCheckoutCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String connectionName, @QueryParameter String checkoutCredentialsId) {
if (context == null && !Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER) ||
context != null && !context.hasPermission(Item.EXTENDED_READ)) {
return new StandardListBoxModel().includeCurrentValue(checkoutCredentialsId);
}
StandardListBoxModel result = new StandardListBoxModel();
result.add("- anonymous -", CHECKOUT_CREDENTIALS_ANONYMOUS);
return result.includeMatchingAs(
context instanceof Queue.Task
? Tasks.getDefaultAuthenticationOf((Queue.Task) context)
: ACL.SYSTEM,
context,
StandardUsernameCredentials.class,
SettingsUtils.gitLabConnectionRequirements(connectionName),
GitClient.CREDENTIALS_MATCHER
);
}
示例7: doFillConnectionIdItems
import hudson.model.Item; //导入依赖的package包/类
/**
* Fills in the Host Connection selection box with applicable connections.
*
* @param context
* filter for host connections
* @param connectionId
* an existing host connection identifier; can be null
* @param project
* the Jenkins project
*
* @return host connection selections
*/
public ListBoxModel doFillConnectionIdItems(@AncestorInPath Jenkins context, @QueryParameter String connectionId,
@AncestorInPath Item project)
{
CpwrGlobalConfiguration globalConfig = CpwrGlobalConfiguration.get();
HostConnection[] hostConnections = globalConfig.getHostConnections();
ListBoxModel model = new ListBoxModel();
model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));
for (HostConnection connection : hostConnections)
{
boolean isSelected = false;
if (connectionId != null)
{
isSelected = connectionId.matches(connection.getConnectionId());
}
model.add(new Option(connection.getDescription() + " [" + connection.getHostPort() + ']', //$NON-NLS-1$
connection.getConnectionId(), isSelected));
}
return model;
}
示例8: doFillCredentialsIdItems
import hudson.model.Item; //导入依赖的package包/类
/**
* Fills in the Login Credentials selection box with applicable connections.
*
* @param context
* filter for login credentials
* @param credentialsId
* existing login credentials; can be null
* @param project
* the Jenkins project
*
* @return login credentials selection
*/
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId,
@AncestorInPath Item project)
{
List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
Collections.<DomainRequirement> emptyList());
ListBoxModel model = new ListBoxModel();
model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));
for (StandardUsernamePasswordCredentials c : creds)
{
boolean isSelected = false;
if (credentialsId != null)
{
isSelected = credentialsId.matches(c.getId());
}
String description = Util.fixEmptyAndTrim(c.getDescription());
model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
c.getId(), isSelected));
}
return model;
}
示例9: testConfigureBuildFilterParameter
import hudson.model.Item; //导入依赖的package包/类
@Test
public void testConfigureBuildFilterParameter() throws Exception {
RunFilterParameter param = new RunFilterParameter(
"PARAM",
"description",
new AndRunFilter(
new ParametersRunFilter("PARAM1=VALUE1"),
new SavedRunFilter()
)
);
WorkflowJob job = j.jenkins.createProject(
WorkflowJob.class,
RandomStringUtils.randomAlphanumeric(7)
);
job.addProperty(new ParametersDefinitionProperty(param));
j.configRoundtrip((Item)job);
j.assertEqualDataBoundBeans(
param,
job.getProperty(ParametersDefinitionProperty.class)
.getParameterDefinition("PARAM")
);
}
示例10: doFillCredentialsIdItems
import hudson.model.Item; //导入依赖的package包/类
/**
* Fills in the Login Credentials selection box with applicable Jenkins credentials.
*
* @param context
* filter for credentials
* @param credentialsId
* existing login credentials; can be null
* @param project
* the Jenkins project
*
* @return credential selections
*/
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId, @AncestorInPath Item project)
{
List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
Collections.<DomainRequirement> emptyList());
StandardListBoxModel model = new StandardListBoxModel();
model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));
for (StandardUsernamePasswordCredentials c : creds)
{
boolean isSelected = false;
if (credentialsId != null)
{
isSelected = credentialsId.matches(c.getId());
}
String description = Util.fixEmptyAndTrim(c.getDescription());
model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
c.getId(), isSelected));
}
return model;
}
示例11: getLoginInformation
import hudson.model.Item; //导入依赖的package包/类
/**
* Retrieves login information given a credential ID.
*
* @param project
* the Jenkins project
*
* @return a Jenkins credential with login information
*/
protected StandardUsernamePasswordCredentials getLoginInformation(Item project)
{
StandardUsernamePasswordCredentials credential = null;
List<StandardUsernamePasswordCredentials> credentials = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());
IdMatcher matcher = new IdMatcher(getCredentialsId());
for (StandardUsernamePasswordCredentials c : credentials)
{
if (matcher.matches(c))
{
credential = c;
}
}
return credential;
}
示例12: getLoginInformation
import hudson.model.Item; //导入依赖的package包/类
/**
* Retrieves login information given a credential ID
*
* @param project
* the Jenkins project
*
* @return a Jenkins credential with login information
*/
protected StandardUsernamePasswordCredentials getLoginInformation(Item project)
{
StandardUsernamePasswordCredentials credential = null;
List<StandardUsernamePasswordCredentials> credentials = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());
IdMatcher matcher = new IdMatcher(getCredentialsId());
for (StandardUsernamePasswordCredentials c : credentials)
{
if (matcher.matches(c))
{
credential = c;
}
}
return credential;
}
示例13: find
import hudson.model.Item; //导入依赖的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;
}
示例14: checkForDuplicates
import hudson.model.Item; //导入依赖的package包/类
@CheckForNull
private static FormValidation checkForDuplicates(String value, ModelObject context, ModelObject object) {
for (CredentialsStore store : CredentialsProvider.lookupStores(object)) {
if (!store.hasPermission(CredentialsProvider.VIEW)) {
continue;
}
ModelObject storeContext = store.getContext();
for (Domain domain : store.getDomains()) {
if (CredentialsMatchers.firstOrNull(store.getCredentials(domain), CredentialsMatchers.withId(value))
!= null) {
if (storeContext == context) {
return FormValidation.error("This ID is already in use");
} else {
return FormValidation.warning("The ID ‘%s’ is already in use in %s", value,
storeContext instanceof Item
? ((Item) storeContext).getFullDisplayName()
: storeContext.getDisplayName());
}
}
}
}
return null;
}
示例15: doFillCredentialsIDItems
import hudson.model.Item; //导入依赖的package包/类
public static ListBoxModel doFillCredentialsIDItems(@AncestorInPath Jenkins context) {
if (context == null || !context.hasPermission(Item.CONFIGURE)) {
return new StandardListBoxModel();
}
List<DomainRequirement> domainRequirements = new ArrayList<DomainRequirement>();
return new StandardListBoxModel()
.withEmptySelection()
.withMatching(
CredentialsMatchers.anyOf(
CredentialsMatchers.instanceOf(ConduitCredentials.class)),
CredentialsProvider.lookupCredentials(
StandardCredentials.class,
context,
ACL.SYSTEM,
domainRequirements));
}