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

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

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

Jenkins.getActiveInstance介绍

暂无

代码示例

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

  1. @Deprecated
  2. public GroovyHookScript(String hook) {
  3. this(hook, Jenkins.getActiveInstance());
  4. }

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

  1. @Override
  2. protected int run() throws Exception {
  3. Jenkins.getActiveInstance().doCancelQuietDown();
  4. return 0;
  5. }
  6. }

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

  1. @Override
  2. protected int run() throws Exception {
  3. Jenkins.getActiveInstance().doQuietDown(block, timeout);
  4. return 0;
  5. }
  6. }

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

  1. @Override
  2. protected Iterable<Node> getNodes() {
  3. return Jenkins.getActiveInstance().getNodes();
  4. }

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

  1. private static File getTargetFile(String name) {
  2. return new File(Jenkins.getActiveInstance().getPluginManager().rootDir,name+".jpi");
  3. }
  4. }

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

  1. protected UnlabeledNodesIterator() {
  2. super(Jenkins.getActiveInstance().getNodes().iterator());
  3. }

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

  1. /**
  2. * Computes the key that identifies this Hudson among other Hudsons that the user has a credential for.
  3. */
  4. @VisibleForTesting
  5. String getPropertyKey() {
  6. Jenkins j = Jenkins.getActiveInstance();
  7. String url = j.getRootUrl();
  8. if (url!=null) return url;
  9. return j.getLegacyInstanceId();
  10. }

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

  1. /**
  2. * Get the stored version of Jenkins, as stored by
  3. * {@link #doConfigSubmit(org.kohsuke.stapler.StaplerRequest, org.kohsuke.stapler.StaplerResponse)}.
  4. * <p>
  5. * Parses the version into {@link VersionNumber}, or null if it's not parseable as a version number
  6. * (such as when Jenkins is run with "mvn hudson-dev:run")
  7. * @since 2.0
  8. */
  9. @Restricted(NoExternalUse.class)
  10. public @CheckForNull static VersionNumber getStoredVersion() {
  11. return toVersion(Jenkins.getActiveInstance().version);
  12. }

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

  1. /**
  2. * URLs to download from.
  3. */
  4. public List<String> getUrls() {
  5. List<String> updateSites = new ArrayList<String>();
  6. for (UpdateSite site : Jenkins.getActiveInstance().getUpdateCenter().getSiteList()) {
  7. String siteUrl = site.getUrl();
  8. int baseUrlEnd = siteUrl.indexOf("update-center.json");
  9. if (baseUrlEnd != -1) {
  10. String siteBaseUrl = siteUrl.substring(0, baseUrlEnd);
  11. updateSites.add(siteBaseUrl + "updates/" + url);
  12. } else {
  13. LOGGER.log(Level.WARNING, "Url {0} does not look like an update center:", siteUrl);
  14. }
  15. }
  16. return updateSites;
  17. }

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

  1. @Override
  2. protected int run() throws Exception {
  3. Jenkins.getActiveInstance().getQueue().clear();
  4. return 0;
  5. }

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

  1. @Override
  2. protected int run() {
  3. // this allows the caller to manipulate the JVM state, so require the admin privilege.
  4. Jenkins.getActiveInstance().checkPermission(Jenkins.RUN_SCRIPTS);
  5. // this being remote means no jline capability is available
  6. System.setProperty("jline.terminal", UnsupportedTerminal.class.getName());
  7. TerminalFactory.reset();
  8. StringBuilder commandLine = new StringBuilder();
  9. for (String arg : args) {
  10. if (commandLine.length() > 0) {
  11. commandLine.append(" ");
  12. }
  13. commandLine.append(arg);
  14. }
  15. Groovysh shell = createShell(stdin, stdout, stderr);
  16. return shell.run(commandLine.toString());
  17. }

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

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

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

  1. @Override
  2. public Object onConvert(Type targetType, Class targetTypeErasure, Object jsonSource) {
  3. if (jsonSource instanceof JSONObject) {
  4. JSONObject json = (JSONObject) jsonSource;
  5. if (isApplicable(targetTypeErasure, json)) {
  6. LOGGER.log(Level.FINE, "switching to newInstance {0} {1}", new Object[] {targetTypeErasure.getName(), json});
  7. try {
  8. return Jenkins.getActiveInstance().getDescriptor(targetTypeErasure).newInstance(Stapler.getCurrentRequest(), json);
  9. } catch (Exception x) {
  10. LOGGER.log(Level.WARNING, "falling back to default instantiation " + targetTypeErasure.getName() + " " + json, x);
  11. }
  12. }
  13. } else {
  14. LOGGER.log(Level.FINER, "ignoring non-object {0}", jsonSource);
  15. }
  16. return oldInterceptor.onConvert(targetType, targetTypeErasure, jsonSource);
  17. }

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

  1. public void doCommand(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
  2. final Jenkins jenkins = Jenkins.getActiveInstance();
  3. jenkins.checkPermission(Jenkins.READ);
  4. // Strip trailing slash
  5. final String commandName = req.getRestOfPath().substring(1);
  6. CLICommand command = CLICommand.clone(commandName);
  7. if (command == null) {
  8. rsp.sendError(HttpServletResponse.SC_NOT_FOUND, "No such command");
  9. return;
  10. }
  11. req.setAttribute("command", command);
  12. req.getView(this, "command.jelly").forward(req, rsp);
  13. }

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

  1. @RequirePOST
  2. public HttpResponse doDoUninstall() throws IOException {
  3. Jenkins jenkins = Jenkins.getActiveInstance();
  4. jenkins.checkPermission(Jenkins.ADMINISTER);
  5. archive.delete();
  6. // Redo who depends on who.
  7. jenkins.getPluginManager().resolveDependantPlugins();
  8. return HttpResponses.redirectViaContextPath("/pluginManager/installed"); // send back to plugin manager
  9. }

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

  1. /**
  2. * Auto-discovers {@link OptionHandler}s and add them to the given command line parser.
  3. */
  4. protected void registerOptionHandlers() {
  5. try {
  6. for (Class c : Index.list(OptionHandlerExtension.class, Jenkins.getActiveInstance().pluginManager.uberClassLoader,Class.class)) {
  7. Type t = Types.getBaseClass(c, OptionHandler.class);
  8. CmdLineParser.registerHandler(Types.erasure(Types.getTypeArgument(t,0)), c);
  9. }
  10. } catch (IOException e) {
  11. throw new Error(e);
  12. }
  13. }

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

  1. protected void runCli(Connection c) throws IOException, InterruptedException {
  2. ChannelBuilder cb;
  3. String name = "CLI channel from " + socket.getInetAddress();
  4. // Connection can contain cipher wrapper, which can't be NIO-ed.
  5. // if (hub!=null)
  6. // cb = hub.newChannelBuilder(name, Computer.threadPoolForRemoting);
  7. // else
  8. cb = new ChannelBuilder(name, Computer.threadPoolForRemoting);
  9. Channel channel = cb
  10. .withMode(Mode.BINARY)
  11. .withRestricted(true)
  12. .withBaseLoader(Jenkins.getActiveInstance().pluginManager.uberClassLoader)
  13. .build(new BufferedInputStream(c.in), new BufferedOutputStream(c.out));
  14. channel.setProperty(CliEntryPoint.class.getName(),new CliManagerImpl(channel));
  15. channel.join();
  16. }
  17. }

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

  1. @Override
  2. protected int run() throws Exception {
  3. final Jenkins jenkins = Jenkins.getActiveInstance();
  4. jenkins.checkPermission(View.CREATE);
  5. View newView;
  6. try {
  7. newView = View.createViewFromXML(viewName, stdin);
  8. } catch (Failure ex) {
  9. throw new IllegalArgumentException("Invalid view name: " + ex.getMessage());
  10. }
  11. final String newName = newView.getViewName();
  12. if (jenkins.getView(newName) != null) {
  13. throw new IllegalStateException("View '" + newName + "' already exists");
  14. }
  15. jenkins.addView(newView);
  16. return 0;
  17. }
  18. }

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

  1. @Override
  2. protected int run() throws Exception {
  3. if (!Jenkins.getActiveInstance().hasPermission(Jenkins.READ)) {
  4. throw new AccessDeniedException("You must authenticate to access this Jenkins.\n"
  5. + CLI.usage());
  6. }
  7. if (command != null)
  8. return showCommandDetails();
  9. showAllCommands();
  10. return 0;
  11. }

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

  1. @Override
  2. protected int run() throws Exception {
  3. final Jenkins jenkins = Jenkins.getActiveInstance();
  4. jenkins.checkPermission(Computer.CREATE);
  5. final Node newNode = (Node) Jenkins.XSTREAM2.fromXML(stdin);
  6. if (nodeName != null) {
  7. // Using deprecated method but it's contract is preserved
  8. newNode.setNodeName(nodeName);
  9. }
  10. if(newNode instanceof Slave) { //change userId too
  11. User user = User.current();
  12. ((Slave) newNode).setUserId(user==null ? "anonymous" : user.getId());
  13. }
  14. if (jenkins.getNode(newNode.getNodeName()) != null) {
  15. throw new IllegalStateException("Node '" + newNode.getNodeName() + "' already exists");
  16. }
  17. jenkins.addNode(newNode);
  18. return 0;
  19. }

相关文章

Jenkins类方法