jenkins.model.Jenkins类的使用及代码示例

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

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

Jenkins介绍

[英]Root object of the system.
[中]系统的根对象。

代码示例

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

/**
 * Returns all the registered {@link CrumbIssuer} descriptors.
 */
public static DescriptorExtensionList<CrumbIssuer, Descriptor<CrumbIssuer>> all() {
  return Jenkins.getInstance().<CrumbIssuer, Descriptor<CrumbIssuer>>getDescriptorList(CrumbIssuer.class);
}

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

@Override
public String getUrlName() {
  String urlName = Jenkins.getInstance().getRootUrl() + URL_NAME;
  return urlName;
}

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

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

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

/**
   * All the registered {@link ChannelConfigurator}s.
   */
  public static ExtensionList<ChannelConfigurator> all() {
    return Jenkins.getInstance().getExtensionList(ChannelConfigurator.class);
  }
}

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

@Override
public Object fromString(String string) {
  Object item = Jenkins.getInstance().getItemByFullName(string);
  if(item==null)  throw new NoSuchElementException("No such job exists: "+string);
  return item;
}

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

public FormValidation doCheckURIEncoding(StaplerRequest request) throws IOException {
    Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
    // expected is non-ASCII String
    final String expected = "\u57f7\u4e8b";
    final String value = fixEmpty(request.getParameter("value"));
    if (!expected.equals(value))
      return FormValidation.warningWithMarkup(hudson.model.Messages.Hudson_NotUsesUTF8ToDecodeURL());
    return FormValidation.ok();
  }
}

代码示例来源:origin: groupon/DotCi

public Iterable<DynamicProject> getJobsFor(final String url) {
  return Iterables.filter(Jenkins.getInstance().getAllItems(DynamicProject.class), new Predicate<DynamicProject>() {
    @Override
    public boolean apply(final DynamicProject input) {
      final GitUrl gitUrl = new GitUrl(url);
      final String[] orgRepo = gitUrl.getFullRepoName().split("/");
      return input.getParent().getName().equalsIgnoreCase(orgRepo[0]) && input.getName().equals(orgRepo[1]);
    }
  });
}

代码示例来源: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: jenkinsci/jenkins

@Override
public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
  String url = this.url;
  if (url.startsWith("/")) {
    StaplerRequest req = Stapler.getCurrentRequest();
    if (req!=null) {
      // if we are serving HTTP request, we want to use app relative URL
      url = req.getContextPath()+url;
    } else {
      // otherwise presumably this is rendered for e-mails and other non-HTTP stuff
      url = Jenkins.getInstance().getRootUrl()+url.substring(1);
    }
  }
  text.addMarkup(charPos, charPos + length, "<a href='" + url + "'"+extraAttributes()+">", "</a>");
  return null;
}

代码示例来源:origin: io.jenkins.jenkinsfile-runner/payload

/**
 * Main entry point invoked by the setup module
 */
public int run(Bootstrap bootstrap) throws Exception {
  Jenkins j = Jenkins.getInstance();
  WorkflowJob w = j.createProject(WorkflowJob.class, "job");
  w.addProperty(new DurabilityHintJobProperty(FlowDurabilityHint.PERFORMANCE_OPTIMIZED));
  w.setDefinition(new CpsScmFlowDefinition(
      new FileSystemSCM(bootstrap.jenkinsfile.getParent()), bootstrap.jenkinsfile.getName()));
  QueueTaskFuture<WorkflowRun> f = w.scheduleBuild2(0,
      new SetJenkinsfileLocation(bootstrap.jenkinsfile));
  b = f.getStartCondition().get();
  writeLogTo(System.out);
  f.get();    // wait for the completion
  return b.getResult().ordinal;
}

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

@Override
  public void evaluate() throws Throwable {
    WorkflowJob job = story.j.jenkins.createProject(WorkflowJob.class, jobName);
    CpsFlowDefinition def = new CpsFlowDefinition("node {\n " +
        "  sleep 30 \n" +
        "  dir('nothing'){sleep 30;}\n"+
        "} \n" +
        "echo 'I like chese'\n", false);
    TestDurabilityHintProvider provider = Jenkins.get().getExtensionList(TestDurabilityHintProvider.class).get(0);
    provider.registerHint(jobName, FlowDurabilityHint.PERFORMANCE_OPTIMIZED);
    job.setDefinition(def);
    WorkflowRun run = job.scheduleBuild2(0).getStartCondition().get();
    Thread.sleep(2000L);  // Hacky but we just need to ensure this can start up
  }
});

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

Jenkins j = Jenkins.getInstance();
o.put("install", j.getLegacyInstanceId());
o.put("servletContainer", j.servletContext.getServerInfo());
o.put("version", Jenkins.VERSION);
for( Computer c : j.getComputers() ) {
  JSONObject  n = new JSONObject();
  if(c.getNode()==j) {
  DescriptorImpl descriptor = j.getDescriptorByType(DescriptorImpl.class);
  n.put("os", descriptor.get(c));
  nodes.add(n);
for( PluginWrapper pw : j.getPluginManager().getPlugins() ) {
  if(!pw.isActive())  continue;   // treat disabled plugins as if they are uninstalled
  JSONObject p = new JSONObject();
for (TopLevelItem item: j.allItems(TopLevelItem.class)) {
  TopLevelItemDescriptor d = item.getDescriptor();
  for (int i = 0; i < descriptors.length; i++) {

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

@Override
protected void submit(StaplerRequest req) throws IOException, ServletException, FormException {
  String proxiedViewName = req.getSubmittedForm().getString("proxiedViewName");
  if (Jenkins.getInstance().getView(proxiedViewName) == null) {
    throw new FormException("Not an existing global view", "proxiedViewName");
  }
  this.proxiedViewName = proxiedViewName;
}

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

public HttpResponse doTest() {
  String referer = Stapler.getCurrentRequest().getReferer();
  Jenkins j = Jenkins.getInstance();
  // May need to send an absolute URL, since handling of HttpRedirect with a relative URL does not currently honor X-Forwarded-Proto/Port at all.
  String redirect = j.getRootUrl() + "administrativeMonitor/" + id + "/testForReverseProxySetup/" + (referer != null ? Util.rawEncode(referer) : "NO-REFERER") + "/";
  LOGGER.log(Level.FINE, "coming from {0} and redirecting to {1}", new Object[] {referer, redirect});
  return new HttpRedirect(redirect);
}

代码示例来源:origin: carlossg/jenkins-kubernetes-plugin

@Test
public void runInPodWithRestartWithMultipleContainerCalls() throws Exception {
  story.then(r -> {
    configureCloud();
    r.jenkins.addNode(new DumbSlave("slave", "dummy", tmp.newFolder("remoteFS").getPath(), "1",
        Node.Mode.NORMAL, "", new JNLPLauncher(), RetentionStrategy.NOOP,
        Collections.<NodeProperty<?>>emptyList())); // TODO JENKINS-26398 clumsy
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
    p.setDefinition(new CpsFlowDefinition(loadPipelineScript("runInPodWithRestartWithMultipleContainerCalls.groovy")
        , true));
    WorkflowRun b = p.scheduleBuild2(0).waitForStart();
    // we need to wait until we are sure that the sh
    // step has started...
    r.waitForMessage("+ sleep 5", b);
  });
  story.then(r -> {
    WorkflowRun b = r.jenkins.getItemByFullName("p", WorkflowJob.class).getBuildByNumber(1);
    r.assertLogContains("finished the test!", r.assertBuildStatusSuccess(r.waitForCompletion(b)));
  });
}

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

private static void checkPermissionForValidate() {
  AccessControlled subject = Stapler.getCurrentRequest().findAncestorObject(AbstractProject.class);
  if (subject == null)
    Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
  else
    subject.checkPermission(Item.CONFIGURE);
}

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

protected final void sendError(String message, StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
  req.setAttribute("message",message);
  req.setAttribute("pre",true);
  rsp.forward(Jenkins.getInstance(),"error",req);
}

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

/**
 * Ignore the problem and go back to using Hudson.
 */
@RequirePOST
public void doIgnore(StaplerRequest req, StaplerResponse rsp) throws IOException {
  ignore = true;
  Jenkins.getInstance().servletContext.setAttribute("app", Jenkins.getInstance());
  rsp.sendRedirect2(req.getContextPath()+'/');
}

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

GitLabPushTrigger.DescriptorImpl oldConfig = Trigger.all().get(GitLabPushTrigger.DescriptorImpl.class);
if (!oldConfig.jobsMigrated) {
  GitLabConnectionConfig gitLabConfig = (GitLabConnectionConfig) Jenkins.getInstance().getDescriptor(GitLabConnectionConfig.class);
  gitLabConfig.getConnections().add(new GitLabConnection(
    oldConfig.gitlabHostUrl,
  for (AbstractProject<?, ?> project : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
    GitLabPushTrigger trigger = project.getTrigger(GitLabPushTrigger.class);
    if (trigger != null) {
  for (AbstractProject<?, ?> project : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
    GitLabPushTrigger trigger = project.getTrigger(GitLabPushTrigger.class);
    if (trigger != null) {

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

public static void checkTriggers(final Calendar cal) {
  Jenkins inst = Jenkins.getInstance();
  SCMTrigger.DescriptorImpl scmd = inst.getDescriptorByType(SCMTrigger.DescriptorImpl.class);
  if (scmd.synchronousPolling) {
    LOGGER.fine("using synchronous polling");
  for (ParameterizedJobMixIn.ParameterizedJob<?, ?> p : inst.allItems(ParameterizedJobMixIn.ParameterizedJob.class)) {
    for (Trigger t : p.getTriggers().values()) {
      if (!(t instanceof SCMTrigger && scmd.synchronousPolling)) {

相关文章

微信公众号

最新文章

更多

Jenkins类方法