Java 类hudson.model.Descriptor 实例源码

项目:jenkins-keycloak-plugin    文件:KeycloakSecurityRealm.java   
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws hudson.model.Descriptor.FormException {
    json = json.getJSONObject("keycloak");
    keycloakJson = json.getString("keycloakJson");
    save();
    return true;
}
项目:mirrorgate-jenkins-builds-collector    文件:MirrorGatePublisher.java   
public FormValidation doTestConnection(
        @QueryParameter("mirrorGateAPIUrl") final String mirrorGateAPIUrl,
        @QueryParameter("mirrorgateCredentialsId") final String credentialsId)
        throws Descriptor.FormException {
    MirrorGateService testMirrorGateService = getMirrorGateService();
    if (testMirrorGateService != null) {
        MirrorGateResponse response
                = testMirrorGateService.testConnection();
        return response.getResponseCode() == HttpStatus.SC_OK
                ? FormValidation.ok("Success")
                : FormValidation.error("Failure<"
                        + response.getResponseCode() + ">");
    } else {
        return FormValidation.error("Failure");
    }
}
项目:jenkins-nomad    文件:NomadSlave.java   
public NomadSlave(
    NomadCloud cloud,
    String name,
    String nodeDescription,
    NomadSlaveTemplate template,
    String labelString,
    Mode mode,
    hudson.slaves.RetentionStrategy retentionStrategy,
    List<? extends NodeProperty<?>> nodeProperties
) throws Descriptor.FormException, IOException {
    super(
        name,
        nodeDescription,
        template.getRemoteFs(),
        template.getNumExecutors(),
        mode,
        labelString,
        new JNLPLauncher(),
        retentionStrategy,
        nodeProperties
    );

    this.cloud = cloud;
}
项目:run-selector-plugin    文件:RunFilter.java   
/**
 * @return all descriptors of {@link RunFilter} without {@link NoRunFilter}
 */
public static List<RunFilterDescriptor> all() {
    Jenkins j = Jenkins.getInstance();
    if (j == null) {
        return Collections.emptyList();
    }
    return Lists.transform(
            j.getDescriptorList(RunFilter.class),
            new Function<Descriptor<?>, RunFilterDescriptor>() {
                @Override
                public RunFilterDescriptor apply(Descriptor<?> arg0) {
                    return (RunFilterDescriptor)arg0;
                }
            }
    );
}
项目:run-selector-plugin    文件:FallbackRunSelector.java   
/**
 * @return descriptors of all {@link RunSelector} except {@link FallbackRunSelector}
 */
public Iterable<? extends Descriptor<? extends RunSelector>> getRunSelectorDescriptorList() {
    Jenkins jenkins = Jenkins.getInstance();
    if (jenkins == null) {
        return Collections.emptyList();
    }
    // remove FallbackRunSelector itself.
    return Iterables.filter(
            jenkins.getDescriptorList(RunSelector.class),
            new Predicate<Descriptor<? extends RunSelector>>() {
                @Override
                public boolean apply(Descriptor<? extends RunSelector> d) {
                    return !FallbackRunSelector.class.isAssignableFrom(d.clazz);
                }
            }
    );
}
项目: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;
}
项目:jira-ext-plugin    文件:JiraPublisherStepTest.java   
@Test
public void testInvokeOperations()
        throws Exception
{
    IssueStrategyExtension mockStrategy = mock(IssueStrategyExtension.class);
    JiraOperationExtension mockOperation = mock(JiraOperationExtension.class);
    Descriptor mockDescriptor = mock(Descriptor.class);
    when(mockDescriptor.getDisplayName()).thenReturn("Mock descriptor");
    when(mockOperation.getDescriptor()).thenReturn(mockDescriptor);
    JiraExtPublisherStep publisher = new JiraExtPublisherStep(mockStrategy,
            Arrays.asList(mockOperation));
    List<JiraCommit> commits = Arrays.asList(new JiraCommit("JENKINS-101",
            MockChangeLogUtil.mockChangeLogSetEntry("example ticket")));

    when(mockStrategy.getJiraCommits(any(AbstractBuild.class), any(BuildListener.class)))
            .thenReturn(commits);

    assertTrue(publisher.perform(mock(AbstractBuild.class), mock(Launcher.class),
            new StreamBuildListener(System.out, Charset.defaultCharset())));
    verify(mockOperation).perform(eq(commits), any(AbstractBuild.class), any(Launcher.class), any(BuildListener.class));
}
项目:jira-ext-plugin    文件:JiraBuildStepPublisherTest.java   
@Test
public void testInvokeOperations()
{
    IssueStrategyExtension mockStrategy = mock(IssueStrategyExtension.class);
    JiraOperationExtension mockOperation = mock(JiraOperationExtension.class);
    Descriptor mockDescriptor = mock(Descriptor.class);
    when(mockDescriptor.getDisplayName()).thenReturn("Mock descriptor");
    when(mockOperation.getDescriptor()).thenReturn(mockDescriptor);
    JiraExtBuildStep builder = new JiraExtBuildStep(mockStrategy,
            Arrays.asList(mockOperation));
    List<JiraCommit> commits = Arrays.asList(new JiraCommit("JENKINS-101",
                    MockChangeLogUtil.mockChangeLogSetEntry("example ticket")));

    when(mockStrategy.getJiraCommits(any(AbstractBuild.class), any(BuildListener.class)))
                .thenReturn(commits);

    assertTrue(builder.perform(mock(AbstractBuild.class), mock(Launcher.class), new StreamBuildListener(System.out)));
    verify(mockOperation).perform(eq(commits), any(AbstractBuild.class), any(Launcher.class), any(BuildListener.class));
}
项目:jenkinslint-plugin    文件:TimeoutChecker.java   
public boolean executeCheck(Item item) {
    boolean notfound = true;
    if (Jenkins.getInstance().pluginManager.getPlugin("build-timeout") != null) {
        if (item.getClass().getName().endsWith("hudson.maven.MavenModuleSet")) {
            try {
                Method method = item.getClass().getMethod("getBuildWrappersList");
                DescribableList<BuildWrapper,Descriptor<BuildWrapper>> buildWrapperList = ((DescribableList<BuildWrapper,Descriptor<BuildWrapper>>) method.invoke(item));
                notfound = !isTimeout(buildWrapperList);
            } catch (Exception e) {
                LOG.log(Level.WARNING, "Exception " + e.getMessage(), e.getCause());
                notfound = false;
            }
        }
        if (item instanceof Project) {
            notfound = !isTimeout(((Project) item).getBuildWrappersList());
        }
        if (item instanceof MatrixProject) {
            notfound = !isTimeout(((MatrixProject) item).getBuildWrappersList());
        }
    }
    return notfound;
}
项目:jenkinslint-plugin    文件:ArtifactChecker.java   
public boolean executeCheck(Item item) {
    LOG.log(Level.FINE, "executeCheck " + item);

    if (item instanceof Project) {
        Project project = (Project) item;
        DescribableList<Publisher, Descriptor<Publisher>> publishersList = project.getPublishersList();
        for (Publisher publisher : publishersList) {
            if (publisher instanceof ArtifactArchiver) {
                LOG.log(Level.FINEST, "ArtifactChecker " + publisher);
                return (((ArtifactArchiver) publisher).getArtifacts() == null ||
                        (((ArtifactArchiver) publisher).getArtifacts() != null &&
                                ((ArtifactArchiver) publisher).getArtifacts().length() == 0));
            }
        }
    }
    return false;
}
项目:yet-another-docker-plugin    文件:DockerSlave.java   
public DockerSlave(String slaveName, String nodeDescription, ComputerLauncher launcher, String containerId,
                   DockerSlaveTemplate dockerSlaveTemplate, String cloudId, ProvisioningActivity.Id provisioningId)
        throws IOException, Descriptor.FormException {
    super(slaveName,
            nodeDescription, //description
            dockerSlaveTemplate.getRemoteFs(),
            dockerSlaveTemplate.getNumExecutors(),
            dockerSlaveTemplate.getMode(),
            dockerSlaveTemplate.getLabelString(),
            launcher,
            dockerSlaveTemplate.getRetentionStrategyCopy(),
            dockerSlaveTemplate.getNodeProperties()
    );
    this.displayName = slaveName; // initial value
    this.containerId = containerId;
    this.cloudId = cloudId;
    setDockerSlaveTemplate(dockerSlaveTemplate);
    this.provisioningId = provisioningId;
}
项目:jenkins-datadog-plugin    文件:DatadogJobProperty.java   
/**
 * This method is called whenever the Job form is saved. We use the 'on' property
 * to determine if the controls are selected.
 *
 * @param req - The request
 * @param form - A JSONObject containing the submitted form data from the job configuration
 * @return a {@link JobProperty} object representing the tagging added to the job
 * @throws hudson.model.Descriptor.FormException if querying of form throws an error
 */
@Override
public JobProperty<?> reconfigure(StaplerRequest req, @Nonnull JSONObject form)
        throws Descriptor.FormException {

  DatadogJobProperty prop = (DatadogJobProperty) super.reconfigure(req, form);
  System.out.println(form);
  boolean isEnableFile = form.getBoolean("enableFile");
  boolean isEnableTagProperties = form.getBoolean("enableProperty");

  if(!isEnableFile) {
      prop.tagFile = null;
      prop.emitOnCheckout = false;
  }
  if(!isEnableTagProperties) {
      prop.tagProperties = null;
  }


  return prop;
}
项目:DotCi    文件:DotCiExtensionsHelper.java   
public <T extends DotCiExtension> T create(String pluginName, Object options, Class<T> extensionClass) {
    for (T adapter : all(extensionClass)) {
        if (adapter.getName().equals(pluginName)) {
            try {
                adapter = (T) adapter.getClass().newInstance();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            adapter.setOptions(options);
            return adapter;
        }

    }

    for (Descriptor<?> pluginDescriptor : getDescriptors()) {
        if (pluginDescriptor.clazz.getSimpleName().equals(pluginName)) {
            return (T) new GenericSimpleBuildStepPlugin(pluginDescriptor, options);
        }
    }
    throw new InvalidBuildConfigurationException("Plugin " + pluginName + " not supported");
}
项目:jenkins-kubernetes-plugin    文件:KubernetesSlave.java   
@DataBoundConstructor
public KubernetesSlave(PodTemplate template, String nodeDescription, String cloudName, String labelStr,
                       RetentionStrategy rs)
        throws Descriptor.FormException, IOException {

    super(getSlaveName(template),
            nodeDescription,
            template.getRemoteFs(),
            1,
            template.getNodeUsageMode() != null ? template.getNodeUsageMode() : Node.Mode.NORMAL,
            labelStr == null ? null : labelStr,
            new KubernetesLauncher(),
            rs,
            template.getNodeProperties());

    this.cloudName = cloudName;
    this.namespace = Util.fixEmpty(template.getNamespace());
    this.template = template;
}
项目:deployer-framework-plugin    文件:DeployTargetDescriptor.java   
/**
 * Returns the {@link DeploySourceDescriptor}s that are valid for the specific context.
 *
 * @param origins the valid origins.
 * @param jobType the project type.
 * @return the {@link DeploySourceDescriptor}s that are valid for the specific context.
 */
@SuppressWarnings("unused") // used by stapler
@NonNull
public List<DeploySourceDescriptor> getDeploySourceDescriptors(@CheckForNull Set<DeploySourceOrigin> origins,
                                                               @CheckForNull Class<? extends AbstractProject>
                                                                       jobType) {
    List<DeploySourceDescriptor> result = new ArrayList<DeploySourceDescriptor>();
    if (origins != null) {
        for (Descriptor<DeploySource> d : Hudson.getInstance().getDescriptorList(DeploySource.class)) {
            if (d instanceof DeploySourceDescriptor) {
                DeploySourceDescriptor descriptor = (DeploySourceDescriptor) d;
                for (DeploySourceOrigin source : origins) {
                    if (descriptor.isSupported(source) && descriptor.isApplicable(jobType)) {
                        if ((isFileTarget() && descriptor.isFileSource())
                                || (isDirectoryTarget() && descriptor.isDirectorySource())) {
                            result.add(descriptor);
                        }
                        break;
                    }
                }
            }
        }
    }
    return result;
}
项目:multi-branch-project-plugin    文件:TemplateDrivenMultiBranchProject.java   
/**
 * Sets various implementation-specific fields and forwards wrapped req/rsp objects on to the
 * {@link #template}'s {@link AbstractProject#doConfigSubmit(StaplerRequest, StaplerResponse)} method.
 * <br>
 * {@inheritDoc}
 */
@Override
public void submit(StaplerRequest req, StaplerResponse rsp)
        throws ServletException, Descriptor.FormException, IOException {
    super.submit(req, rsp);

    makeDisabled(req.getParameter("disable") != null);

    template.doConfigSubmit(
            new TemplateStaplerRequestWrapper(req),
            new TemplateStaplerResponseWrapper(req.getStapler(), rsp));

    ItemListener.fireOnUpdated(this);

    // notify the queue as the project might be now tied to different node
    Jenkins.getActiveInstance().getQueue().scheduleMaintenance();

    // this is to reflect the upstream build adjustments done above
    Jenkins.getActiveInstance().rebuildDependencyGraphAsync();
}
项目:yaml-project-plugin    文件:DisplayNameYamlTransformProvider.java   
public DisplayNameYamlTransformProvider() {
  this(new Supplier<List<Descriptor>>() {
        @Override
        public List<Descriptor> get() {
          List<Descriptor> descriptors = Lists.newArrayList();
          ExtensionList<Descriptor> extensions =
              checkNotNull(Jenkins.getInstance())
              .getExtensionList(Descriptor.class);
          for (ExtensionComponent<Descriptor> component :
                   extensions.getComponents()) {
            descriptors.add(component.getInstance());
          }
          return descriptors;
        }
      });
}
项目:yaml-project-plugin    文件:DisplayNameYamlTransformProvider.java   
public ByNameTransform(List<Descriptor> descriptors) {
  final Map<String, Class> byName = Maps.newHashMap();
  final Map<Class, String> byClass = Maps.newHashMap();

  for (Descriptor descriptor : descriptors) {
    final Class clazz = descriptor.clazz;
    final String displayName = descriptor.getDisplayName();

    // The first time we see it, add it to the byName map
    if (!byName.containsKey(displayName)) {
      byName.put(displayName, clazz);
      byClass.put(clazz, displayName);
    } else {
      // Subsequent visitations, replace the byName entry
      // with a sentinel value and remove the original Class
      // from the map.
      byClass.remove(byName.get(displayName));
      byName.put(displayName, COLLISION_SENTINEL);
    }
  }

  // Assign as immutable entities to our fields.
  this.byName = Collections.unmodifiableMap(byName);
  this.byClass = Collections.unmodifiableMap(byClass);
}
项目:yaml-project-plugin    文件:FilteredDescribableList.java   
/**
 * Validates that the given $class is present on the Jenkins master,
 * and appropriately typed for the expected $class of describable.
 * @throws BadTypeException is there are any issues
 */
private void validateClass(String className,
    Collection<? extends Descriptor<T>> descriptors) {
  final ClassLoader baseLoader =
      checkNotNull(Jenkins.getInstance()).getPluginManager().uberClassLoader;
  try {
    final Class type = baseLoader.loadClass(className);
    final Descriptor<T> descriptor =
        checkNotNull(Jenkins.getInstance()).getDescriptor(type);

    if (!descriptors.contains(descriptor)) {
      throw new BadTypeException(
          Messages.FilteredDescribableList_NotInList(className));
    }
  } catch (ClassNotFoundException e) {
    // TODO(mattmoor): and if its an unknown tag?  then what happens?
    throw new BadTypeException(
        Messages.FilteredDescribableList_Unavailable(className));
  }
}
项目:yaml-project-plugin    文件:Binder.java   
/** {@inheritDoc} */
@Override
public <T extends Describable> T bind(JSONObject json)
    throws IOException, FormException {
  final String clazz = checkNotNull(json.optString("$class", null));

  final Descriptor descriptor = getDescriptor(clazz);

  final Stapler stapler = getStapler();
  final StaplerRequest request = getRequest(stapler, json);

  // We do this instead of 'request.bindJson' because this doesn't
  // require a DataBoundConstructor.
  // TODO(mattmoor): Should we do the rewrite of describable lists
  // here as well?
  return (T) descriptor.newInstance(request, json);
}
项目:yaml-project-plugin    文件:Binder.java   
/**
 * Gets the {@link Descriptor} of the {@link Describable} we are
 * looking to instantiate.
 */
@VisibleForTesting
Descriptor getDescriptor(String clazzName) throws IOException {
  Class<? extends Describable<?>> implClass;
  try {
    implClass = (Class<? extends Describable<?>>) getClassLoader()
        .loadClass(clazzName);
  } catch (ClassNotFoundException ex) {
    throw new BadTypeException(
        Messages.DefaultBinder_CannotLoadClass(clazzName));
  }

  final Descriptor descriptor =
      checkNotNull(Jenkins.getInstance()).getDescriptor(implClass);
  if (descriptor == null) {
    throw new BadTypeException(
        Messages.DefaultBinder_NoDescriptor(implClass.getName()));
  }
  return descriptor;
}
项目:yaml-project-plugin    文件:AbstractRunnableItemGroup.java   
/** {@inheritDoc} */
@Override
public DescribableList<Publisher, Descriptor<Publisher>> getPublishersList() {
  // TODO(mattmoor): switch to utilize something with an atomic
  // compare/exchange semantic.
  if (publishers != null) {
    return publishers;
  }

  // NOTE: I believe this is lazily initialized vs. created in the
  // constructor so that lazy API consumers can omit an empty publisher list
  // from their serialized XML blob.
  synchronized (this) {
    if (publishers == null) {
      publishers =
          new DescribableList<Publisher, Descriptor<Publisher>>(this);
    }
  }

  return publishers;
}
项目:docker-build-step-plugin    文件:StopAllCommand.java   
@Override
public void execute(Launcher launcher, @SuppressWarnings("rawtypes") AbstractBuild build, ConsoleLogger console)
        throws DockerException {
    try {
        Config cfgData = getConfig(build);
        Descriptor<?> descriptor = Jenkins.getInstance().getDescriptor(DockerBuilder.class);

        List<Container> containers = launcher.getChannel().call(new ListContainersRemoteCallable(cfgData, descriptor, false));

        for (Container container : containers) {
            launcher.getChannel().call(new StopContainerRemoteCallable(cfgData, descriptor, container.getId()));
            console.logInfo("stoped container id " + container.getId());
        }
    } catch (Exception e) {
        console.logError("failed to stop all containers");
        e.printStackTrace();
        throw new IllegalArgumentException(e);
    }
}
项目:docker-build-step-plugin    文件:KillCommand.java   
@Override
public void execute(Launcher launcher, @SuppressWarnings("rawtypes") AbstractBuild build, ConsoleLogger console)
        throws DockerException {
    if (containerIds == null || containerIds.isEmpty()) {
        throw new IllegalArgumentException("At least one parameter is required");
    }

    String containerIdsRes = Resolver.buildVar(build, containerIds);
    List<String> ids = Arrays.asList(containerIdsRes.split(","));

    Config cfgData = getConfig(build);
    Descriptor<?> descriptor = Jenkins.getInstance().getDescriptor(DockerBuilder.class);
    for (String id : ids) {
        id = id.trim();

        try {
            launcher.getChannel().call(new KillContainerRemoteCallable(cfgData, descriptor, id));
            console.logInfo("killed container id " + id);
        } catch (Exception e) {
            console.logError("failed to kill containers " + ids);
            e.printStackTrace();
            throw new IllegalArgumentException(e);
        }
    }
}
项目:docker-build-step-plugin    文件:RestartCommand.java   
@Override
public void execute(Launcher launcher, @SuppressWarnings("rawtypes") AbstractBuild build, ConsoleLogger console) throws DockerException {
    if (containerIds == null || containerIds.isEmpty()) {
        throw new IllegalArgumentException("At least one parameter is required");
    }

    String containerIdsRes = Resolver.buildVar(build, containerIds);
    List<String> ids = Arrays.asList(containerIdsRes.split(","));

    try {
        Config cfgData = getConfig(build);
        Descriptor<?> descriptor = Jenkins.getInstance().getDescriptor(DockerBuilder.class);

        for (String id : ids) {
            id = id.trim();
            launcher.getChannel().call(new RestartContainerRemoteCallable(cfgData, descriptor, id, timeout));
            console.logInfo("restarted container id " + id);
        }
    } catch (Exception e) {
        console.logError("failed to restart containers ids " + ids);
        e.printStackTrace();
        throw new IllegalArgumentException(e);
    }
}
项目:docker-build-step-plugin    文件:CreateContainerRemoteCallable.java   
public CreateContainerRemoteCallable(Config cfgData, Descriptor<?> descriptor, String imageRes, String[] commandRes,
        String hostNameRes, String containerNameRes, String linksRes, String[] envVarsRes, String exposedPortsRes,
        Integer cpuSharesRes, Long memoryLimitRes, String[] dnsRes, String[] extraHostsRes,
        String portBindingsRes, String bindMountsRes, boolean alwaysRestart, boolean publishAllPorts,
        boolean privileged) {
    this.cfgData = cfgData;
    this.descriptor = descriptor;
    this.imageRes = imageRes;
    this.commandRes = commandRes;
    this.hostNameRes = hostNameRes;
    this.containerNameRes = containerNameRes;
    this.linksRes = linksRes;
    this.envVarsRes = envVarsRes;
    this.exposedPortsRes = exposedPortsRes;
    this.cpuSharesRes = cpuSharesRes;
    this.memoryLimitRes = memoryLimitRes;
    this.dnsRes = dnsRes;
    this.extraHostsRes = extraHostsRes;
    this.portBindingsRes = portBindingsRes;
    this.bindMountsRes = bindMountsRes;
    this.alwaysRestart = alwaysRestart;
    this.publishAllPorts = publishAllPorts;
    this.privileged = privileged;
}
项目:docker-build-step-plugin    文件:RemoveAllCommand.java   
@Override
public void execute(Launcher launcher, @SuppressWarnings("rawtypes") AbstractBuild build, ConsoleLogger console)
        throws DockerException {


    try {
        Config cfgData = getConfig(build);
        Descriptor<?> descriptor = Jenkins.getInstance().getDescriptor(DockerBuilder.class);

        List<Container> containers = launcher.getChannel().call(new ListContainersRemoteCallable(cfgData, descriptor, false));

        for (Container container : containers) {
            launcher.getChannel().call(new RemoveContainerRemoteCallable(cfgData, descriptor, container.getId(), force, removeVolumes));
            console.logInfo("removed container id " + container.getId());
        }
    } catch (Exception e) {
        console.logError("failed to stop all containers");
        e.printStackTrace();
        throw new IllegalArgumentException(e);
    }

}
项目:docker-build-step-plugin    文件:StopByImageIdCommand.java   
@Override
public void execute(Launcher launcher, @SuppressWarnings("rawtypes") AbstractBuild build, ConsoleLogger console)
        throws DockerException {
    if (imageId == null || imageId.isEmpty()) {
        throw new IllegalArgumentException("At least one parameter is required");
    }

    String imageIdRes = Resolver.buildVar(build, imageId);

    try {
        Config cfgData = getConfig(build);
        Descriptor<?> descriptor = Jenkins.getInstance().getDescriptor(DockerBuilder.class);

        List<Container> containers = launcher.getChannel().call(new ListContainersRemoteCallable(cfgData, descriptor, false));
        for (Container container : containers) {
            if (imageIdRes.equalsIgnoreCase(container.getImage())) {
                launcher.getChannel().call(new StopContainerRemoteCallable(cfgData, descriptor, container.getId()));
                console.logInfo("stoped container id " + container.getId());
            }
        }
    } catch (Exception e) {
        console.logError("failed to stop containers by imageIdRes " + imageIdRes);
        e.printStackTrace();
        throw new IllegalArgumentException(e);
    }
}
项目:p4-jenkins    文件:P4ChangeEntry.java   
public P4ChangeEntry(P4ChangeSet parent) {
    super();
    setParent(parent);

    jobs = new ArrayList<IFix>();
    affectedFiles = new ArrayList<P4AffectedFile>();

    Jenkins j = Jenkins.getInstance();
    if (j != null) {
        Descriptor dsc = j.getDescriptor(PerforceScm.class);
        if (dsc instanceof PerforceScm.DescriptorImpl) {
            PerforceScm.DescriptorImpl p4scm = (PerforceScm.DescriptorImpl) dsc;
            fileCountLimit = p4scm.getMaxFiles();
        }
    }
}
项目:gitea-plugin    文件:GiteaSCMNavigator.java   
public List<SCMTrait<? extends SCMTrait<?>>> getTraitsDefaults() {
    GiteaSCMSource.DescriptorImpl descriptor =
            ExtensionList.lookup(Descriptor.class).get(GiteaSCMSource.DescriptorImpl.class);
    if (descriptor == null) {
        throw new AssertionError();
    }
    List<SCMTrait<? extends SCMTrait<?>>> result = new ArrayList<>();
    result.addAll(descriptor.getTraitsDefaults());
    return result;
}
项目:Jenkins-Plugin-Examples    文件:CoreStep.java   
public Collection<? extends Descriptor<?>> getApplicableDescriptors() {
    // Jenkins.instance.getDescriptorList(SimpleBuildStep) is empty, presumably because that itself is not a Describable.
    List<Descriptor<?>> r = new ArrayList<>();
    populate(r, Builder.class);
    populate(r, Publisher.class);
    return r;
}
项目:Jenkins-Plugin-Examples    文件:CoreStep.java   
private <T extends Describable<T>,D extends Descriptor<T>> void populate(List<Descriptor<?>> r, Class<T> c) {
    for (Descriptor<?> d : Jenkins.getActiveInstance().getDescriptorList(c)) {
        if (SimpleBuildStep.class.isAssignableFrom(d.clazz)) {
            r.add(d);
        }
    }
}
项目:asf-gitpubsub-jenkins-plugin    文件:ASFGitSCMNavigator.java   
/**
 * Populates the available trait descriptors.
 *
 * @return the available trait descriptors.
 */
@SuppressWarnings("unused") // jelly
public List<NamedArrayList<? extends SCMTraitDescriptor<?>>> getTraitsDescriptorLists() {
    GitSCMSource.DescriptorImpl sourceDescriptor =
            ExtensionList.lookup(Descriptor.class).get(GitSCMSource.DescriptorImpl.class);
    List<SCMTraitDescriptor<?>> all = new ArrayList<>();
    all.addAll(SCMNavigatorTrait._for(this, ASFGitSCMNavigatorContext.class, ASFGitSCMSourceBuilder.class));
    all.addAll(SCMSourceTrait._for(sourceDescriptor, GitSCMSourceContext.class, null));
    all.addAll(SCMSourceTrait._for(sourceDescriptor, null, GitSCMBuilder.class));
    Set<SCMTraitDescriptor<?>> dedup = new HashSet<>();
    for (Iterator<SCMTraitDescriptor<?>> iterator = all.iterator(); iterator.hasNext(); ) {
        SCMTraitDescriptor<?> d = iterator.next();
        if (dedup.contains(d)
                || d instanceof GitBrowserSCMSourceTrait.DescriptorImpl) {
            // remove any we have seen already and ban the browser configuration as it will always be github
            iterator.remove();
        } else {
            dedup.add(d);
        }
    }
    List<NamedArrayList<? extends SCMTraitDescriptor<?>>> result = new ArrayList<>();
    NamedArrayList.select(all, Messages.ASFGitSCMNavigator_ASFGitSCMNaviagort_repositories(),
            new NamedArrayList.Predicate<SCMTraitDescriptor<?>>() {
                @Override
                public boolean test(SCMTraitDescriptor<?> scmTraitDescriptor) {
                    return scmTraitDescriptor instanceof SCMNavigatorTraitDescriptor;
                }
            },
            true, result);
    NamedArrayList.select(all, Messages.ASFGitSCMNavigator_withinRepositories(),
            NamedArrayList.anyOf(NamedArrayList.withAnnotation(Discovery.class),
                    NamedArrayList.withAnnotation(Selection.class)),
            true, result);
    NamedArrayList.select(all, Messages.ASFGitSCMNavigator_additionalBehaviours(), null, true, result);
    return result;
}
项目:asf-gitpubsub-jenkins-plugin    文件:ASFGitSCMNavigator.java   
/**
 * Populate the default traits for new instances.
 *
 * @return the default traits.
 */
public List<SCMTrait<? extends SCMTrait<?>>> getTraitsDefaults() {
    GitSCMSource.DescriptorImpl descriptor =
            ExtensionList.lookup(Descriptor.class).get(GitSCMSource.DescriptorImpl.class);
    if (descriptor == null) {
        throw new AssertionError();
    }
    List<SCMTrait<? extends SCMTrait<?>>> result = new ArrayList<>();
    result.addAll(descriptor.getTraitsDefaults());
    return result;
}
项目:custom-notifier-plugin    文件:JobListener.java   
private JdumpService getService(AbstractBuild builder, TaskListener listener) {

        Map<Descriptor<Publisher>, Publisher> map = builder.getProject().getPublishersList().toMap();
        for (Publisher publisher : map.values()) {
            if (publisher instanceof JdumpNotifier) {
                return ((JdumpNotifier) publisher).newJdumpService(builder, listener);
            }
        }
        return null;
    }
项目:mirrorgate-jenkins-builds-collector    文件:MirrorGatePublisher.java   
@Override
public boolean configure(StaplerRequest sr, JSONObject formData)
        throws Descriptor.FormException {
    mirrorGateAPIUrl = sr.getParameter("mirrorGateAPIUrl");
    mirrorgateCredentialsId = sr.getParameter("_.mirrorgateCredentialsId");
    extraURLs = sr.getParameter("extraURLs");

    save();
    return super.configure(sr, formData);
}
项目:run-selector-plugin    文件:RunSelectorParameter.java   
public DescriptorExtensionList<RunSelector,Descriptor<RunSelector>> getRunSelectors() {
    Jenkins jenkins = Jenkins.getInstance();
    if (jenkins == null) {
        return DescriptorExtensionList.createDescriptorList((Jenkins)null, RunSelector.class);
    }
    return jenkins.<RunSelector,Descriptor<RunSelector>>getDescriptorList(RunSelector.class);
}
项目:run-selector-plugin    文件:RunSelectorParameter.java   
/**
 * @return {@link RunSelector}s available for RunSelectorParameter.
 */
public List<Descriptor<RunSelector>> getAvailableRunSelectorList() {
    Jenkins jenkins = Jenkins.getInstance();
    if (jenkins == null) {
        return Collections.emptyList();
    }
    return Lists.newArrayList(Collections2.filter(
            jenkins.getDescriptorList(RunSelector.class),
            new Predicate<Descriptor<RunSelector>>() {
                public boolean apply(Descriptor<RunSelector> input) {
                    return !"ParameterizedRunSelector".equals(input.clazz.getSimpleName());
                };
            }
    ));
}
项目:run-selector-plugin    文件:RunSelectorParameter.java   
@Initializer(after = InitMilestone.PLUGINS_STARTED)
public static void initAliases() {
    Jenkins jenkins = Jenkins.getInstance();
    if (jenkins == null) {
        LOGGER.severe("Called for initialization but Jenkins instance no longer available.");
        return;
    }
    // Alias all RunSelectors to their simple names
    for (Descriptor<RunSelector> d : jenkins.getDescriptorByType(DescriptorImpl.class).getRunSelectors())
        XSTREAM.alias(d.clazz.getSimpleName(), d.clazz);
}
项目:pipeline-bitbucket-server-steps-plugin    文件:SetCommitStatusStep.java   
@DataBoundConstructor
public SetCommitStatusStep(String serverUrl, String credentials, String commitId, String state, String key, String url)
        throws Descriptor.FormException {
    this.serverUrl = serverUrl;
    this.credentials = credentials;
    this.commitId = commitId;
    this.state = state;
    this.key = key;
    this.url = url;

    if (StringUtils.isBlank(serverUrl)) {
        throw new Descriptor.FormException("Can not be empty", "serverUrl");
    }
    if (StringUtils.isBlank(credentials)) {
        throw new Descriptor.FormException("Can not be empty", "credentials");
    }
    if (StringUtils.isBlank(commitId)) {
        throw new Descriptor.FormException("Can not be empty", "commitId");
    }
    if (StringUtils.isBlank(state)) {
        throw new Descriptor.FormException("Can not be empty", "state");
    }
    if (StringUtils.isBlank(key)) {
        throw new Descriptor.FormException("Can not be empty", "key");
    }
    if (StringUtils.isBlank(url)) {
        throw new Descriptor.FormException("Can not be empty", "url");
    }
}