Package jenkins.model

Examples of jenkins.model.Jenkins


     *            the plug-in to check
     * @return <code>true</code> if the specified plug-in is installed,
     *         <code>false</code> if not.
     */
    public static boolean isPluginInstalled(final String shortName) {
        Jenkins instance = Jenkins.getInstance();
        if (instance != null) {
            return instance.getPlugin(shortName) != null;
        }
        return true;
    }
View Full Code Here


                              @QueryParameter String hostname)
            throws IOException, FormException {
        // bypass the regular security check
        SecurityContextHolder.getContext().setAuthentication(ACL.SYSTEM);
        try {
            final Jenkins jenkins = Jenkins.getInstance();

            if (defaultPrefix != null && !defaultPrefix.isEmpty()) {
                name = defaultPrefix + "-" + name;
            }

            if (description == null) {
                description = "";
            }

            labels = defaultLabels + " " + Util.fixNull(labels);

            DynaSlave slave = new DynaSlave(name, "Dynamic slave at " + hostname + ": " + description,
                    remoteFsRoot, String.valueOf(executors), labels, hostname, defaultRemoteSlaveUser,
                    defaultBaseLauncherCommand, defaultIdleTerminationMinutes);

            synchronized (jenkins) {
                Node n = jenkins.getNode(name);
                if (n != null) jenkins.removeNode(n);
                jenkins.addNode(slave);
            }
        } catch (FormException e) {
            LOG.log(Level.WARNING, "Unable to create dynaslave:", e);

        } finally {
View Full Code Here

    private static final String AT_DOMAIN = "@DOMAIN";

    @Before
    public void before() throws Exception {
        final Jenkins jenkins = PowerMockito.mock(Jenkins.class);
        final ExtendedEmailPublisherDescriptor extendedEmailPublisherDescriptor = PowerMockito.mock(ExtendedEmailPublisherDescriptor.class);
        PowerMockito.when(jenkins.getDescriptorByType(ExtendedEmailPublisherDescriptor.class)).thenReturn(extendedEmailPublisherDescriptor);
        PowerMockito.mockStatic(Jenkins.class);
        PowerMockito.doReturn(jenkins).when(Jenkins.class, "getInstance");

        final Mailer.DescriptorImpl descriptor = PowerMockito.mock(Mailer.DescriptorImpl.class);
        PowerMockito.when(descriptor.getDefaultSuffix()).thenReturn("DOMAIN");
View Full Code Here

    /**
     * Bare-minimum configuration mechanism to change the update center.
     */
    public HttpResponse doSiteConfigure(@QueryParameter String site) throws IOException {
        Jenkins hudson = Jenkins.getInstance();
        hudson.checkPermission(Jenkins.ADMINISTER);
        UpdateCenter uc = hudson.getUpdateCenter();
        PersistedList<UpdateSite> sites = uc.getSites();
        for (UpdateSite s : sites) {
            if (s.getId().equals("default"))
                sites.remove(s);
        }
View Full Code Here

        return HttpResponses.redirectToContextRoot();
    }


    public HttpResponse doProxyConfigure(StaplerRequest req) throws IOException, ServletException {
        Jenkins jenkins = Jenkins.getInstance();
        jenkins.checkPermission(Jenkins.ADMINISTER);

        ProxyConfiguration pc = req.bindJSON(ProxyConfiguration.class, req.getSubmittedForm());
        if (pc.name==null) {
            jenkins.proxy = null;
            ProxyConfiguration.getXmlFile().delete();
View Full Code Here

    @Override
    public Object unmarshal(HierarchicalStreamReader reader, Object root, DataHolder dataHolder) {
        // init() is too early to do this
        // defensive because some use of XStream happens before plugins are initialized.
        Jenkins h = Jenkins.getInstance();
        if(h!=null && h.pluginManager!=null && h.pluginManager.uberClassLoader!=null) {
            setClassLoader(h.pluginManager.uberClassLoader);
        }

        Object o = super.unmarshal(reader,root,dataHolder);
View Full Code Here

            initThread = new Thread("hudson initialization thread") {
                @Override
                public void run() {
                    boolean success = false;
                    try {
                        Jenkins instance = new Hudson(home, context);
                        context.setAttribute(APP, instance);

                        // at this point we are open for business and serving requests normally
                        LOGGER.info("Jenkins is fully up and running");
                        success = true;
                    } catch (Error e) {
                        LOGGER.log(Level.SEVERE, "Failed to initialize Jenkins",e);
                        context.setAttribute(APP,new HudsonFailedToLoad(e));
                        throw e;
                    } catch (Exception e) {
                        LOGGER.log(Level.SEVERE, "Failed to initialize Jenkins",e);
                        context.setAttribute(APP,new HudsonFailedToLoad(e));
                    } finally {
                        Jenkins instance = Jenkins.getInstance();
                        if(!success && instance!=null)
                            instance.cleanUp();
                    }
                }
            };
            initThread.start();
        } catch (Error e) {
View Full Code Here

        return new FileAndDescription(newHome,"$user.home/.jenkins");
    }

    public void contextDestroyed(ServletContextEvent event) {
        terminated = true;
        Jenkins instance = Jenkins.getInstance();
        if(instance!=null)
            instance.cleanUp();
        Thread t = initThread;
        if (t!=null)
            t.interrupt();

        // Logger is in the system classloader, so if we don't do this
View Full Code Here

    /**
     * Replaces the current {@link Node} by another one.
     */
    private void replaceBy(Node newNode) throws ServletException, IOException {
        final Jenkins app = Jenkins.getInstance();

        // replace the old Node object by the new one
        synchronized (app) {
            List<Node> nodes = new ArrayList<Node>(app.getNodes());
            int i = nodes.indexOf(getNode());
            if(i<0) {
                throw new IOException("This slave appears to be removed while you were editing the configuration");
            }

            nodes.set(i, newNode);
            app.setNodes(nodes);
        }
    }
View Full Code Here

     * Used for CLI binding.
     */
    @CLIResolver
    public static Computer resolveForCLI(
            @Argument(required=true,metaVar="NAME",usage="Slave name, or empty string for master") String name) throws CmdLineException {
        Jenkins h = Jenkins.getInstance();
        Computer item = h.getComputer(name);
        if (item==null) {
            List<String> names = new ArrayList<String>();
            for (Computer c : h.getComputers())
                if (c.getName().length()>0)
                    names.add(c.getName());
            throw new CmdLineException(null,Messages.Computer_NoSuchSlaveExists(name,EditDistance.findNearest(name,names)));
        }
        return item;
View Full Code Here

TOP

Related Classes of jenkins.model.Jenkins

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.