當前位置: 首頁>>代碼示例>>Java>>正文


Java Jenkins.getInstance方法代碼示例

本文整理匯總了Java中jenkins.model.Jenkins.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java Jenkins.getInstance方法的具體用法?Java Jenkins.getInstance怎麽用?Java Jenkins.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jenkins.model.Jenkins的用法示例。


在下文中一共展示了Jenkins.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildProxyConfiguration

import jenkins.model.Jenkins; //導入方法依賴的package包/類
/**
 * build proxy for cloud foundry http connection
 * @param targetURL - target API URL
 * @return the full target URL
 */
private static HttpProxyConfiguration buildProxyConfiguration(URL targetURL) {
    ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy;
    if (proxyConfig == null) {
        return null;
    }

    String host = targetURL.getHost();
    for (Pattern p : proxyConfig.getNoProxyHostPatterns()) {
        if (p.matcher(host).matches()) {
            return null;
        }
    }

    return new HttpProxyConfiguration(proxyConfig.name, proxyConfig.port);
}
 
開發者ID:IBM,項目名稱:ibm-cloud-devops,代碼行數:21,代碼來源:AbstractDevOpsAction.java

示例2: doEndOfflineAgentJobs

import jenkins.model.Jenkins; //導入方法依賴的package包/類
public void doEndOfflineAgentJobs(final StaplerRequest request, final StaplerResponse response) {

		Jenkins j;
		if ((j = Jenkins.getInstance()) != null) {
			Queue queue = j.getQueue();
			if (queue != null) {
				for (Item job : queue.getItems()) {
					if (job.getCauseOfBlockage() instanceof BecauseNodeIsOffline
							|| job.getCauseOfBlockage() instanceof BecauseLabelIsOffline) {
						queue.cancel(job);
					}
				}
			}
		}

		try {
			response.sendRedirect2(request.getRootPath());
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
開發者ID:jenkinsci,項目名稱:no-agent-job-purge-plugin,代碼行數:22,代碼來源:PurgeNoAgentJobs.java

示例3: all

import jenkins.model.Jenkins; //導入方法依賴的package包/類
/**
 * @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;
                }
            }
    );
}
 
開發者ID:jenkinsci,項目名稱:run-selector-plugin,代碼行數:19,代碼來源:RunFilter.java

示例4: getRunSelectorDescriptorList

import jenkins.model.Jenkins; //導入方法依賴的package包/類
/**
 * @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);
                }
            }
    );
}
 
開發者ID:jenkinsci,項目名稱:run-selector-plugin,代碼行數:20,代碼來源:FallbackRunSelector.java

示例5: jobLoaded

import jenkins.model.Jenkins; //導入方法依賴的package包/類
@Initializer(before = InitMilestone.COMPLETED, after = InitMilestone.JOB_LOADED)
public static void jobLoaded() throws IOException
{
	m_logger.fine("Initialization milestone: All jobs have been loaded"); //$NON-NLS-1$
	Jenkins jenkins = Jenkins.getInstance();
	for (AbstractProject<?, ?> project : jenkins.getAllItems(AbstractProject.class))
	{
		try
		{
			SCM scmConfig = project.getScm();
			if (scmConfig instanceof AbstractConfiguration && ((AbstractConfiguration) scmConfig).isMigrated())
			{
				project.save();

				m_logger.info(String.format(
								"Project %s has been migrated.", //$NON-NLS-1$
								project.getFullName()));
			}
		}
		catch (IOException e)
		{
			m_logger.log(Level.SEVERE, String.format("Failed to upgrade job %s", project.getFullName()), e); //$NON-NLS-1$
		}
	}
}
 
開發者ID:jenkinsci,項目名稱:compuware-scm-downloader-plugin,代碼行數:26,代碼來源:AbstractConfiguration.java

示例6: removeNode

import jenkins.model.Jenkins; //導入方法依賴的package包/類
private synchronized void removeNode(String instanceId) {
    final Jenkins jenkins=Jenkins.getInstance();
    //noinspection SynchronizationOnLocalVariableOrMethodParameter
    synchronized (jenkins) {
        // If this node is dying, remove it from Jenkins
        final Node n = jenkins.getNode(instanceId);
        if (n != null) {
            try {
                jenkins.removeNode(n);
            } catch(final Exception ex) {
                LOGGER.log(Level.WARNING, "Error removing node " + instanceId);
                throw new IllegalStateException(ex);
            }
        }
    }
}
 
開發者ID:awslabs,項目名稱:ec2-spot-jenkins-plugin,代碼行數:17,代碼來源:EC2FleetCloud.java

示例7: updateFromGlobalConfiguration

import jenkins.model.Jenkins; //導入方法依賴的package包/類
private void updateFromGlobalConfiguration() {
    Jenkins jenkins = Jenkins.getInstance();

    if (jenkins !=  null) {
        GlobalConsulConfig.DescriptorImpl globalDescriptor = (GlobalConsulConfig.DescriptorImpl)
                jenkins.getDescriptor(GlobalConsulConfig.class);

        if (globalDescriptor != null) {
            hostUrl = globalDescriptor.getConsulHostUrl();
            apiUri = globalDescriptor.getConsulApiUri();
            aclToken = globalDescriptor.getConsulAclToken();
            timeoutConnection = globalDescriptor.getConsulTimeoutConnection();
            timeoutResponse = globalDescriptor.getConsulTimeoutResponse();
            debugMode = globalDescriptor.getConsulDebugMode();
        } else {
            LOGGER.warning("Could not load global settings.");
        }
    } else {
        LOGGER.warning("Could not load global settings.");
    }
}
 
開發者ID:jenkinsci,項目名稱:consul-kv-builder-plugin,代碼行數:22,代碼來源:ConsulKVBuilder.java

示例8: updateFromGlobalConfiguration

import jenkins.model.Jenkins; //導入方法依賴的package包/類
/**
 * Loads global settings
 */
public void updateFromGlobalConfiguration() {
    Jenkins jenkins = Jenkins.getInstance();

    if (jenkins !=  null) {
        GlobalConsulConfig.DescriptorImpl globalDescriptor = (GlobalConsulConfig.DescriptorImpl)
                jenkins.getDescriptor(GlobalConsulConfig.class);

        if (globalDescriptor != null) {
            this.hostUrl = globalDescriptor.getConsulHostUrl();
            this.apiUri = globalDescriptor.getConsulApiUri();
            this.aclToken = globalDescriptor.getConsulAclToken();
            this.timeoutConnect = globalDescriptor.getConsulTimeoutConnection();
            this.timeoutResponse = globalDescriptor.getConsulTimeoutResponse();
            this.debugMode = globalDescriptor.getConsulDebugMode();
        } else {
            LOGGER.warning("Could not load global settings.");
        }
    } else {
        LOGGER.warning("Could not load global settings.");
    }
}
 
開發者ID:jenkinsci,項目名稱:consul-kv-builder-plugin,代碼行數:25,代碼來源:ReadBean.java

示例9: jenkinsPluginClassLoader

import jenkins.model.Jenkins; //導入方法依賴的package包/類
public Gitea jenkinsPluginClassLoader() {
    // HACK for Jenkins
    // by rights this should be the context classloader, but Jenkins does not expose plugins on that
    // so we need instead to use the uberClassLoader as that will have the implementations
    Jenkins instance = Jenkins.getInstance();
    classLoader = instance == null ? getClass().getClassLoader() : instance.getPluginManager().uberClassLoader;
    // END HACK
    return this;
}
 
開發者ID:jenkinsci,項目名稱:gitea-plugin,代碼行數:10,代碼來源:Gitea.java

示例10: getMasterNode

import jenkins.model.Jenkins; //導入方法依賴的package包/類
@CheckForNull
private static Node getMasterNode() {
    final Jenkins jenkins  = Jenkins.getInstance();
    if (jenkins == null) {
        return null;
    }
    Computer computer = jenkins.toComputer();
    if (computer == null) {
        return null; //Master can have no executors
    }
    return computer.getNode();
}
 
開發者ID:jenkinsci,項目名稱:envinject-api-plugin,代碼行數:13,代碼來源:EnvVarsResolver.java

示例11: isEnvInjectPluginInstalled

import jenkins.model.Jenkins; //導入方法依賴的package包/類
/**
 * Check if the EnvInject plugin is installed
 * @return {@code true} If the plugin is installed. It may be not activated.
 */
public static boolean isEnvInjectPluginInstalled() {
    final Jenkins jenkins = Jenkins.getInstance();
    if (jenkins == null) {
        return false;
    }
    Plugin envInjectPlugin = jenkins.getPlugin("envinject");
    return envInjectPlugin != null;
}
 
開發者ID:jenkinsci,項目名稱:envinject-api-plugin,代碼行數:13,代碼來源:EnvInjectPluginHelper.java

示例12: injector

import jenkins.model.Jenkins; //導入方法依賴的package包/類
public synchronized static Injector injector() {
    Jenkins jenkins = Jenkins.getInstance();//TODO optimize this code
    if (jenkins != null) {
        InternalInjector internalInjector = jenkins.lookup.setIfNull(InternalInjector.class, new InternalInjector());
        injector = internalInjector.resolve();
    }

    if (injector == null) {
        injector = Guice.createInjector(new Context());
    }
    return injector;
}
 
開發者ID:riboseinc,項目名稱:aws-codecommit-trigger-plugin,代碼行數:13,代碼來源:Context.java

示例13: run

import jenkins.model.Jenkins; //導入方法依賴的package包/類
@Override
public RunWrapper run() throws Exception {

    String jobName = step.getJob();
    if (jobName == null) {
        throw new AbortException(Messages.SelectRunStep_MissingJobParameter());
    }

    Jenkins jenkins = Jenkins.getInstance();
    if (jenkins == null) {
        throw new IllegalStateException("Jenkins has not been started, or was already shut down");
    }
    Job<?, ?> upstreamJob = jenkins.getItem(jobName, run.getParent(), Job.class);
    if (upstreamJob == null) {
        throw new AbortException(Messages.SelectRunStep_MissingJob(jobName));
    }

    RunSelector selector = step.getSelector();
    if (selector == null) {
        listener.getLogger().println(Messages.SelectRunStep_MissingRunSelector(DEFAULT_RUN_SELECTOR.getDisplayName()));
        selector = DEFAULT_RUN_SELECTOR;
    }

    RunFilter filter = step.getFilter();
    if (filter == null) {
        listener.getLogger().println(Messages.SelectRunStep_MissingRunFilter());
        filter = DEFAULT_RUN_FILTER;
    }

    RunSelectorContext context = new RunSelectorContext(jenkins, run, listener, filter);
    context.setVerbose(step.isVerbose());

    Run<?, ?> upstreamRun = selector.select(upstreamJob, context);
    if (upstreamRun == null) {
        throw new AbortException(Messages.SelectRunStep_MissingRun(jobName, selector.getDisplayName(), filter.getDisplayName()));
    }

    return new RunWrapper(upstreamRun, false);
}
 
開發者ID:jenkinsci,項目名稱:run-selector-plugin,代碼行數:40,代碼來源:SelectRunExecution.java

示例14: getRunSelectors

import jenkins.model.Jenkins; //導入方法依賴的package包/類
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);
}
 
開發者ID:jenkinsci,項目名稱:run-selector-plugin,代碼行數:8,代碼來源:RunSelectorParameter.java

示例15: getAvailableRunSelectorList

import jenkins.model.Jenkins; //導入方法依賴的package包/類
/**
 * @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());
                };
            }
    ));
}
 
開發者ID:jenkinsci,項目名稱:run-selector-plugin,代碼行數:18,代碼來源:RunSelectorParameter.java


注:本文中的jenkins.model.Jenkins.getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。