jenkins.model.Jenkins.getDescriptorByType()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(176)

本文整理了Java中jenkins.model.Jenkins.getDescriptorByType()方法的一些代码示例,展示了Jenkins.getDescriptorByType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jenkins.getDescriptorByType()方法的具体详情如下:
包路径:jenkins.model.Jenkins
类名称:Jenkins
方法名:getDescriptorByType

Jenkins.getDescriptorByType介绍

[英]Gets the Descriptor instance in the current Jenkins by its type.
[中]按类型获取当前Jenkins中的描述符实例。

代码示例

代码示例来源:origin: jenkinsci/jenkins

public JDK.DescriptorImpl getJDKDescriptor() {
  return Jenkins.getInstance().getDescriptorByType(JDK.DescriptorImpl.class);
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public void setInstallations(MavenInstallation... installations) {
  Jenkins.getInstance().getDescriptorByType(Maven.DescriptorImpl.class).setInstallations(installations);
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public MavenInstallation[] getInstallations() {
  return Jenkins.getInstance().getDescriptorByType(Maven.DescriptorImpl.class).getInstallations();
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Gets all the job properties configured for this job.
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public Map<JobPropertyDescriptor, JobProperty<? super JobT>> getProperties() {
  Map result = Descriptor.toMap((Iterable) properties);
  if (logRotator != null) {
    result.put(Jenkins.getActiveInstance().getDescriptorByType(BuildDiscarderProperty.DescriptorImpl.class), new BuildDiscarderProperty(logRotator));
  }
  return result;
}

代码示例来源:origin: jenkinsci/jenkins

/**
   * Performs syntax check.
   */
  public FormValidation doCheckScmpoll_spec(@QueryParameter String value,
                       @QueryParameter boolean ignorePostCommitHooks,
                       @AncestorInPath Item item) {
    if (StringUtils.isBlank(value)) {
      if (ignorePostCommitHooks) {
        return FormValidation.ok(Messages.SCMTrigger_no_schedules_no_hooks());
      } else {
        return FormValidation.ok(Messages.SCMTrigger_no_schedules_hooks());
      }
    } else {
      return Jenkins.getInstance().getDescriptorByType(TimerTrigger.DescriptorImpl.class)
          .doCheckSpec(value, item);
    }
  }
}

代码示例来源:origin: jenkinsci/jenkins

SCMTrigger.DescriptorImpl scmd = inst.getDescriptorByType(SCMTrigger.DescriptorImpl.class);
if (scmd.synchronousPolling) {
  LOGGER.fine("using synchronous polling");

代码示例来源:origin: jenkinsci/jenkins

DescriptorImpl descriptor = j.getDescriptorByType(DescriptorImpl.class);
n.put("os", descriptor.get(c));
nodes.add(n);

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

@Test
@Issue("Issue #172")
@ConfiguredWithCode("AdminWhitelistRuleConfigurator/Agent2MasterSecurityKillSwitch_disabled.yml")
public void checkA2MAccessControl_disable() {
  final Jenkins jenkins = Jenkins.getInstance();
  MasterKillSwitchConfiguration config = jenkins.getDescriptorByType(MasterKillSwitchConfiguration.class);
  Assert.assertFalse("Agent → Master Access Control should be disabled", config.getMasterToSlaveAccessControl());
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

@Test
@Issue("Issue #172")
@ConfiguredWithCode("AdminWhitelistRuleConfigurator/Agent2MasterSecurityKillSwitch_enabled.yml")
public void checkA2MAccessControl_enabled() {
  final Jenkins jenkins = Jenkins.getInstance();
  MasterKillSwitchConfiguration config = jenkins.getDescriptorByType(MasterKillSwitchConfiguration.class);
  Assert.assertTrue("Agent → Master Access Control should be enabled", config.getMasterToSlaveAccessControl());
}

代码示例来源:origin: org.jenkins-ci.plugins/credentials

/**
 * Expose {@link CredentialsWrapper.DescriptorImpl} to Jelly.
 *
 * @return the {@link CredentialsWrapper.DescriptorImpl} singleton.
 */
public CredentialsWrapper.DescriptorImpl getCredentialDescriptor() {
  // TODO switch to Jenkins.getInstance() once 2.0+ is the baseline
  return Jenkins.getActiveInstance().getDescriptorByType(CredentialsWrapper.DescriptorImpl.class);
}

代码示例来源:origin: org.jenkins-ci.plugins/credentials

/**
 * Exposes {@link DomainWrapper.DescriptorImpl} for Jelly.
 *
 * @return {@link DomainWrapper.DescriptorImpl}.
 */
public DomainWrapper.DescriptorImpl getDomainDescriptor() {
  // TODO switch to Jenkins.getInstance() once 2.0+ is the baseline
  return Jenkins.getActiveInstance().getDescriptorByType(DomainWrapper.DescriptorImpl.class);
}

代码示例来源:origin: jenkinsci/email-ext-plugin

static RecipientListStringAnalyser newInstance(TaskListener listener, String recipientsListString) {
  ExtendedEmailPublisherDescriptor descriptor = Jenkins.getActiveInstance().getDescriptorByType(
      ExtendedEmailPublisherDescriptor.class);
  return new RecipientListStringAnalyser(listener, descriptor, recipientsListString);
}

代码示例来源:origin: SonarSource/sonar-scanner-jenkins

/**
 * This method is used in UI, so signature and location of this method is important (see SONARPLUGINS-1337).
 *
 * @return all configured {@link hudson.tasks.Maven.MavenInstallation}
 */
public MavenInstallation[] getMavenInstallations() {
 return Jenkins.getInstance().getDescriptorByType(Maven.DescriptorImpl.class).getInstallations();
}

代码示例来源:origin: org.jenkins-ci.plugins/git

@SuppressFBWarnings(value="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification="Jenkins.getInstance() is not null")
public GitTool resolveGitTool(TaskListener listener) {
  if (gitTool == null) return GitTool.getDefaultInstallation();
  GitTool git =  Jenkins.getInstance().getDescriptorByType(GitTool.DescriptorImpl.class).getInstallation(gitTool);
  if (git == null) {
    listener.getLogger().println("Selected Git installation does not exist. Using Default");
    git = GitTool.getDefaultInstallation();
  }
  return git;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Gets all the job properties configured for this job.
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public Map<JobPropertyDescriptor, JobProperty<? super JobT>> getProperties() {
  Map result = Descriptor.toMap((Iterable) properties);
  if (logRotator != null) {
    result.put(Jenkins.getActiveInstance().getDescriptorByType(BuildDiscarderProperty.DescriptorImpl.class), new BuildDiscarderProperty(logRotator));
  }
  return result;
}

代码示例来源:origin: jenkinsci/email-ext-plugin

@Override
public void addRecipients(ExtendedEmailPublisherContext context, EnvVars env, Set<InternetAddress> to, Set<InternetAddress> cc, Set<InternetAddress> bcc) {
  try {
    ExtendedEmailPublisherDescriptor descriptor = Jenkins.getActiveInstance().getDescriptorByType(ExtendedEmailPublisherDescriptor.class);
    descriptor.debug(context.getListener().getLogger(), "Adding recipients from project recipient list");
    EmailRecipientUtils.addAddressesFromRecipientList(to, cc, bcc, EmailRecipientUtils.getRecipientList(context, context.getPublisher().recipientList), env, context.getListener());
  } catch (MessagingException ex) {
    Logger.getLogger(ListRecipientProvider.class.getName()).log(Level.SEVERE, null, ex);
  }
}

代码示例来源:origin: jenkinsci/subversion-plugin

@CheckForNull
public FormValidation doCheckTagsDir(StaplerRequest req, @AncestorInPath Item context, @QueryParameter String value) {
  Jenkins instance = Jenkins.getInstance();
  if (instance != null) {
    SubversionSCM.ModuleLocation.DescriptorImpl desc = instance.getDescriptorByType(SubversionSCM.ModuleLocation.DescriptorImpl.class);
    if (desc != null) {
      return desc.doCheckRemote(req, context, value);
    }
  }
  return FormValidation.warning("Unable to check tags directory.");
}

代码示例来源:origin: jenkinsci/subversion-plugin

public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context, @QueryParameter String tagsDir) {
 if (context == null || !context.hasPermission(Item.EXTENDED_READ)) {
  return new StandardListBoxModel();
 }
 return Jenkins.getInstance().getDescriptorByType(
     SubversionSCM.ModuleLocation.DescriptorImpl.class).fillCredentialsIdItems(context, tagsDir);
}

代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin

@Issue("JENKINS-51027")
@Test
public void buildConditionsHaveDescriptions() throws Exception {
  PostDirective.DescriptorImpl descriptor = r.jenkins.getDescriptorByType(PostDirective.DescriptorImpl.class);
  assertNotNull(descriptor);
  List<BuildCondition> conditions = ExtensionList.lookup(BuildCondition.class);
  assertEquals(conditions.size(), descriptor.getPossibleConditions().size());
}

代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin

@Issue("JENKINS-46809")
@Test
public void toolsInGroup() throws Exception {
  Maven.MavenInstallation maven350 = ToolInstallations.configureMaven35();
  Maven.MavenInstallation maven301 = ToolInstallations.configureMaven3();
  j.jenkins.getDescriptorByType(Maven.DescriptorImpl.class).setInstallations(maven350, maven301);
  expect("toolsInGroup")
      .logContains("Solo: Apache Maven 3.0.1",
          "First in group: Apache Maven 3.5.0",
          "Second in group: Apache Maven 3.0.1")
      .go();
}

相关文章

Jenkins类方法