Java 类hudson.model.AbstractItem 实例源码

项目:browserstack-integration-plugin    文件:BrowserStackCredentials.java   
public static BrowserStackCredentials getCredentials(final AbstractItem buildItem, final String credentialsId) {
    List<BrowserStackCredentials> available = availableCredentials(buildItem);
    if (available.isEmpty()) {
        return null;
    }

    CredentialsMatcher matcher;
    if (credentialsId != null) {
        matcher = CredentialsMatchers.allOf(CredentialsMatchers.withId(credentialsId));
    } else {
        matcher = CredentialsMatchers.always();
    }

    return CredentialsMatchers.firstOrDefault(
            available,
            matcher,
            available.get(0));
}
项目:browserstack-integration-plugin    文件:BrowserStackBuildWrapper.java   
private static <T extends BuildWrapper> BuildWrapperItem<T> findItemWithBuildWrapper(final AbstractItem buildItem, Class<T> buildWrapperClass) {
    if (buildItem == null) {
        return null;
    }

    if (buildItem instanceof BuildableItemWithBuildWrappers) {
        BuildableItemWithBuildWrappers buildWrapper = (BuildableItemWithBuildWrappers) buildItem;
        DescribableList<BuildWrapper, Descriptor<BuildWrapper>> buildWrappersList = buildWrapper.getBuildWrappersList();

        if (buildWrappersList != null && !buildWrappersList.isEmpty()) {
            return new BuildWrapperItem<T>(buildWrappersList.get(buildWrapperClass), buildItem);
        }
    }

    if (buildItem.getParent() instanceof AbstractItem) {
        return findItemWithBuildWrapper((AbstractItem) buildItem.getParent(), buildWrapperClass);
    }

    return null;
}
项目:uno-choice-plugin    文件:AbstractScriptableParameter.java   
/**
 * Inherited constructor.
 *
 * {@inheritDoc}
 *
 * @param name name
 * @param description description
 * @param randomName parameter random generated name (uuid)
 * @param script script used to generate the list of parameter values
 */
protected AbstractScriptableParameter(String name, String description, String randomName, Script script) {
    super(name, description, randomName);
    this.script = script;
    // Try to get the project name from the current request. In case of being called in some other non-web way,
    // the name will be fetched later via Jenkins.getInstance() and iterating through all items. This is for a
    // performance wise approach first.
    final StaplerRequest currentRequest = Stapler.getCurrentRequest();
    String projectName = null;
    if (currentRequest != null) {
        final Ancestor ancestor = currentRequest.findAncestor(AbstractItem.class);
        if (ancestor != null) {
            final Object o = ancestor.getObject();
            if (o instanceof AbstractItem) {
                final AbstractItem parentItem = (AbstractItem) o;
                projectName = parentItem.getName();
            }
        }
    }
    this.projectName = projectName;
}
项目:DotCi    文件:DynamicSubProject.java   
@Override
public void onLoad(final ItemGroup<? extends Item> parent, final String name) throws IOException {
    try {
        final Field parentField = AbstractItem.class.getDeclaredField("parent");
        parentField.setAccessible(true);
        ReflectionUtils.setField(parentField, this, parent);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }

    doSetName(name);
    if (this.transientActions == null) {
        this.transientActions = new Vector<>();
    }
    updateTransientActions();
    getBuildersList().setOwner(this);
    getPublishersList().setOwner(this);
    getBuildWrappersList().setOwner(this);

    initRepos();
}
项目:browserstack-integration-plugin    文件:BrowserStackCredentials.java   
public static List<BrowserStackCredentials> availableCredentials(final AbstractItem abstractItem) {
    return CredentialsProvider.lookupCredentials(
            BrowserStackCredentials.class,
            abstractItem,
            null,
            new ArrayList<DomainRequirement>());
}
项目:gitlab-auth-plugin    文件:GitLabAuthorization.java   
/**
 * Tries to get the ACL of a folder.
 * Otherwise it will return the root ACL of the Authorization Strategy.
 * 
 * @param item the item
 * @return an ACL
 */
@Override
public ACL getACL(AbstractItem item) {
    if (item instanceof Folder) {
        return getACL((Folder) item);
    }
    return getRootACL();
}
项目:yaml-project-plugin    文件:AbstractRestriction.java   
/**
 * @return the {@link ClassLoader} on top of which to layer our restrictions.
 */
protected final ClassLoader getBaseClassLoader(RestrictedProject project) {
  // Search the project's parent hierarchy for additional
  // restricted projects on which to base our restrictions.
  ItemGroup parent = project.asProject().getParent();
  while (parent != null) {
    if (parent instanceof RestrictedProject) {
      final RestrictedProject parentProject = (RestrictedProject) parent;
      return parentProject.getRestriction().getClassLoader(parentProject);
    }
    if (!(parent instanceof AbstractItem)) {
      break;
    }
    parent = ((AbstractItem) parent).getParent();
  }

  // If no parents of this are restricted, then base things on the
  // unrestricted uber class loader.
  // NOTE: we wrap this class loader anyways to surface diagnostics
  // when there are actual class loading failures, so we can surface
  // them to the user.
  final ClassLoader base =
      checkNotNull(Jenkins.getInstance()).getPluginManager().uberClassLoader;
  return new ClassLoader() {
    @Override
    public Class loadClass(String name) throws ClassNotFoundException {
      try {
        return base.loadClass(name);
      } catch (ClassNotFoundException e) {
        throw new BadTypeException(
            Messages.AbstractRestriction_ClassNotFound(name));
      }
    }
  };
}
项目:donut-jenkins-plugin    文件:DonutProjectAction.java   
public DonutProjectAction(AbstractItem item) {
    super();
    this.item = item;
}
项目:donut-jenkins-plugin    文件:DonutProjectAction.java   
private File getProjectArchiveDir(AbstractItem item) {
    return new File(item.getRootDir(), "donut");
}
项目:browserstack-integration-plugin    文件:BrowserStackBuildWrapper.java   
BuildWrapperItem(T buildWrapper, AbstractItem buildItem) {
    this.buildWrapper = buildWrapper;
    this.buildItem = buildItem;
}
项目:Spirent-iTest-Jenkins-Plugin    文件:Report.java   
/**
 * Gets the directory where the HTML report is stored for the given project.
 */
private File getProjectArchiveDir(AbstractItem project) {
    return new File(new File(project.getRootDir(), "htmlreports"), 
            this.getSanitizedName());
}
项目:Spirent-iTest-Jenkins-Plugin    文件:Report.java   
public HTMLAction(AbstractItem project,
        Report actualHtmlPublisherTarget) {
    super(actualHtmlPublisherTarget);
    this.project = project;
}
项目:DotCi    文件:DbBackedProject.java   
@PostLoad
private void restoreName(final DBObject dbObj) {
    GReflectionUtils.setField(AbstractItem.class, "name", this, dbObj.get("name"));
}