本文整理汇总了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);
}
示例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);
}
}
示例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;
}
}
);
}
示例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);
}
}
);
}
示例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$
}
}
}
示例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);
}
}
}
}
示例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.");
}
}
示例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.");
}
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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());
};
}
));
}