本文整理了Java中jenkins.model.Jenkins.getInstance()
方法的一些代码示例,展示了Jenkins.getInstance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jenkins.getInstance()
方法的具体详情如下:
包路径:jenkins.model.Jenkins
类名称:Jenkins
方法名:getInstance
暂无
代码示例来源: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 Object getTarget() {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
return this;
}
代码示例来源:origin: jenkinsci/jenkins
public String getCommand() {
return RunIdMigrator.getUnmigrationCommandLine(Jenkins.getInstance().getRootDir());
}
}
代码示例来源:origin: jenkinsci/jenkins
static <T extends Annotation> List<IndexItem<T,Object>> listDelta(Class<T> annotationType, List<? extends IndexItem<?,Object>> old) {
// list up newly discovered components
final List<IndexItem<T,Object>> delta = Lists.newArrayList();
ClassLoader cl = Jenkins.getInstance().getPluginManager().uberClassLoader;
for (IndexItem<T,Object> ii : Index.load(annotationType, Object.class, cl)) {
if (!old.contains(ii)) {
delta.add(ii);
}
}
return delta;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Returns those node properties which can be configured as global node properties.
*
* @since 1.520
*/
public static List<NodePropertyDescriptor> getGlobalNodePropertyDescriptors() {
List<NodePropertyDescriptor> result = new ArrayList<NodePropertyDescriptor>();
Collection<NodePropertyDescriptor> list = (Collection) Jenkins.getInstance().getDescriptorList(NodeProperty.class);
for (NodePropertyDescriptor npd : list) {
if (npd.isApplicableAsGlobal()) {
result.add(npd);
}
}
return result;
}
代码示例来源:origin: jenkinsci/jenkins
@Initializer(after=EXTENSIONS_AUGMENTED)
public void verify() {
Jenkins h = Jenkins.getInstance();
for (Descriptor d : h.getExtensionList(Descriptor.class)) {
PluginWrapper p = h.getPluginManager().whichPlugin(d.getClass());
String id;
try {
id = d.getId();
} catch (Throwable t) {
LOGGER.log(Level.SEVERE,MessageFormat.format("Descriptor {0} from plugin {1} with display name {2} reported an exception for ID",
d, p == null ? "???" : p.getLongName(), d.getDisplayName()),t);
problems.add(d);
continue;
}
if (id==null) {
LOGGER.severe(MessageFormat.format("Descriptor {0} from plugin {1} with display name {2} has null ID",
d, p==null?"???":p.getLongName(), d.getDisplayName()));
problems.add(d);
}
}
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public List<? extends ToolInstaller> getDefaultInstallers() {
try {
Class<? extends ToolInstaller> jdkInstallerClass = Jenkins.getInstance().getPluginManager()
.uberClassLoader.loadClass("hudson.tools.JDKInstaller").asSubclass(ToolInstaller.class);
Constructor<? extends ToolInstaller> constructor = jdkInstallerClass.getConstructor(String.class, boolean.class);
return Collections.singletonList(constructor.newInstance(null, false));
} catch (ClassNotFoundException e) {
return Collections.emptyList();
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Unable to get default installer", e);
return Collections.emptyList();
}
}
代码示例来源:origin: jenkinsci/jenkins
@RequirePOST
@Deprecated
public HttpResponse doPin() throws IOException {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
// See https://groups.google.com/d/msg/jenkinsci-dev/kRobm-cxFw8/6V66uhibAwAJ
LOGGER.log(WARNING, "Call to pin plugin has been ignored. Plugin name: " + shortName);
return HttpResponses.ok();
}
代码示例来源:origin: jenkinsci/jenkins
private static final File getBaseDir() {
File baseDir;
String baseEnv = System.getenv("BASE");
if (baseEnv != null) {
baseDir = new File(baseEnv);
} else {
LOGGER.log(Level.WARNING, "Could not find environment variable 'BASE' for Jenkins base directory. Falling back to JENKINS_HOME");
baseDir = Jenkins.getInstance().getRootDir();
}
return baseDir;
}
代码示例来源:origin: jenkinsci/jenkins
protected List<String> getPossibleViewNames(String baseName) {
List<String> names = new ArrayList<String>();
for (Facet f : WebApp.get(Jenkins.getInstance().servletContext).facets) {
if (f instanceof JellyCompatibleFacet) {
JellyCompatibleFacet jcf = (JellyCompatibleFacet) f;
for (String ext : jcf.getScriptExtensions())
names.add(baseName +ext);
}
}
return names;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* @deprecated replaced by {@link Slave.SlaveDescriptor#nodePropertyDescriptors(Slave)}
* @since 2.12
*/
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.12")
public static List<NodePropertyDescriptor> getNodePropertyDescriptors(Class<? extends Node> clazz) {
List<NodePropertyDescriptor> result = new ArrayList<NodePropertyDescriptor>();
Collection<NodePropertyDescriptor> list = (Collection) Jenkins.getInstance().getDescriptorList(NodeProperty.class);
for (NodePropertyDescriptor npd : list) {
if (npd.isApplicable(clazz)) {
result.add(npd);
}
}
return result;
}
代码示例来源:origin: jenkinsci/jenkins
public ComputerLauncher getLauncher() {
if (launcher == null && !StringUtils.isEmpty(agentCommand)) {
try {
launcher = (ComputerLauncher) Jenkins.getInstance().getPluginManager().uberClassLoader.loadClass("hudson.slaves.CommandLauncher").getConstructor(String.class, EnvVars.class).newInstance(agentCommand, null);
agentCommand = null;
save();
} catch (Exception x) {
LOGGER.log(Level.WARNING, "could not update historical agentCommand setting to CommandLauncher", x);
}
}
// Default launcher does not use Work Directory
return launcher == null ? new JNLPLauncher(false) : launcher;
}
代码示例来源:origin: jenkinsci/jenkins
@RequirePOST
@Deprecated
public HttpResponse doUnpin() throws IOException {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
// See https://groups.google.com/d/msg/jenkinsci-dev/kRobm-cxFw8/6V66uhibAwAJ
LOGGER.log(WARNING, "Call to unpin plugin has been ignored. Plugin name: " + shortName);
return HttpResponses.ok();
}
代码示例来源:origin: jenkinsci/jenkins
@Override
protected void fix(TaskListener listener) throws Exception {
LOGGER.info("Initiating a re-keying of secrets. See "+getLogFile());
SecretRewriter rewriter = new SecretRewriter();
try {
PrintStream log = listener.getLogger();
log.println("Started re-keying " + new Date());
int count = rewriter.rewriteRecursive(Jenkins.getInstance().getRootDir(), listener);
log.printf("Completed re-keying %d files on %s\n",count,new Date());
new RekeySecretAdminMonitor().done.on();
LOGGER.info("Secret re-keying completed");
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Fatal failure in re-keying secrets",e);
Functions.printStackTrace(e, listener.error("Fatal failure in rewriting secrets"));
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Returns all the registered {@link NodeMonitor} descriptors.
*/
public static DescriptorExtensionList<NodeMonitor,Descriptor<NodeMonitor>> all() {
return Jenkins.getInstance().<NodeMonitor,Descriptor<NodeMonitor>>getDescriptorList(NodeMonitor.class);
}
}
代码示例来源:origin: jenkinsci/jenkins
public DoubleLaunchChecker() {
home = Jenkins.getInstance().getRootDir();
}
代码示例来源:origin: jenkinsci/jenkins
@Override
@Restricted(NoExternalUse.class)
public Object getTarget() {
if (!SKIP_PERMISSION_CHECK) {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
}
return this;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Does the opposite of {@link #toNameList(Collection)}.
*/
public static <T extends Item> List<T> fromNameList(ItemGroup context, @Nonnull String list, @Nonnull Class<T> type) {
final Jenkins jenkins = Jenkins.getInstance();
List<T> r = new ArrayList<T>();
if (jenkins == null) {
return r;
}
StringTokenizer tokens = new StringTokenizer(list,",");
while(tokens.hasMoreTokens()) {
String fullName = tokens.nextToken().trim();
if (StringUtils.isNotEmpty(fullName)) {
T item = jenkins.getItem(fullName, context, type);
if(item!=null)
r.add(item);
}
}
return r;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Returns the list of {@link NodePropertyDescriptor} appropriate to the supplied {@link Slave}.
*
* @param it the {@link Slave} or {@code null} to assume the slave is of type {@link #clazz}.
* @return the filtered list
* @since 2.12
*/
@Nonnull
@SuppressWarnings("unchecked") // used by Jelly EL only
@Restricted(NoExternalUse.class) // used by Jelly EL only
public final List<NodePropertyDescriptor> nodePropertyDescriptors(@CheckForNull Slave it) {
List<NodePropertyDescriptor> result = new ArrayList<NodePropertyDescriptor>();
Collection<NodePropertyDescriptor> list =
(Collection) Jenkins.getInstance().getDescriptorList(NodeProperty.class);
for (NodePropertyDescriptor npd : it == null
? DescriptorVisibilityFilter.applyType(clazz, list)
: DescriptorVisibilityFilter.apply(it, list)) {
if (npd.isApplicable(clazz)) {
result.add(npd);
}
}
return result;
}
代码示例来源:origin: jenkinsci/jenkins
@Initializer(after = InitMilestone.PLUGINS_PREPARED, before = InitMilestone.PLUGINS_STARTED, fatal = false)
public static void load() throws IOException {
Map<String, Boolean> overrides = ExtensionList.lookup(CustomClassFilter.class).get(Contributed.class).overrides;
overrides.clear();
Enumeration<URL> resources = Jenkins.getInstance().getPluginManager().uberClassLoader.getResources("META-INF/hudson.remoting.ClassFilter");
while (resources.hasMoreElements()) {
try (InputStream is = resources.nextElement().openStream()) {
for (String entry : IOUtils.readLines(is, StandardCharsets.UTF_8)) {
if (entry.matches("#.*|\\s*")) {
// skip
} else if (entry.startsWith("!")) {
overrides.put(entry.substring(1), false);
} else {
overrides.put(entry, true);
}
}
}
}
Logger.getLogger(Contributed.class.getName()).log(Level.FINE, "plugin-defined entries: {0}", overrides);
}
内容来源于网络,如有侵权,请联系作者删除!