Package hudson.model

Examples of hudson.model.Hudson


    @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.
        Hudson h = Hudson.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


    }

    private static Future previousSynchronousPolling;

    public static void checkTriggers(final Calendar cal) {
        Hudson inst = Hudson.getInstance();

        // Are we using synchronous polling?
        SCMTrigger.DescriptorImpl scmd = inst.getDescriptorByType(SCMTrigger.DescriptorImpl.class);
        if (scmd.synchronousPolling) {
            LOGGER.fine("using synchronous polling");

            // Check that previous synchronous polling job is done to prevent piling up too many jobs
            if (previousSynchronousPolling == null || previousSynchronousPolling.isDone()) {
                // Process SCMTriggers in the order of dependencies. Note that the crontab spec expressed per-project is
                // ignored, only the global setting is honored. The polling job is submitted only if the previous job has
                // terminated.
                // FIXME allow to set a global crontab spec
                previousSynchronousPolling = scmd.getExecutor().submit(new DependencyRunner(new ProjectRunnable() {
                    public void run(AbstractProject p) {
                        for (Trigger t : (Collection<Trigger>) p.getTriggers().values()) {
                            if (t instanceof SCMTrigger) {
                                LOGGER.fine("synchronously triggering SCMTrigger for project " + t.job.getName());
                                t.run();
                            }
                        }
                    }
                }));
            } else {
                LOGGER.fine("synchronous polling has detected unfinished jobs, will not trigger additional jobs.");
            }
        }

        // Process all triggers, except SCMTriggers when synchronousPolling is set
        for (AbstractProject<?,?> p : inst.getAllItems(AbstractProject.class)) {
            for (Trigger t : p.getTriggers().values()) {
                if (! (t instanceof SCMTrigger && scmd.synchronousPolling)) {
                    LOGGER.fine("cron checking "+p.getName());

                    if (t.tabs.check(cal)) {
View Full Code Here

    /**
     * Periodically invoked to keep track of the load.
     * Launches additional nodes if necessary.
     */
    private void update() {
        Hudson hudson = Hudson.getInstance();

        // clean up the cancelled launch activity, then count the # of executors that we are about to bring up.
        float plannedCapacity = 0;
        for (Iterator<PlannedNode> itr = pendingLaunches.iterator(); itr.hasNext();) {
            PlannedNode f = itr.next();
            if(f.future.isDone()) {
                try {
                    hudson.addNode(f.future.get());
                    LOGGER.info(f.displayName+" provisioning successfully completed. We have now "+hudson.getComputers().length+" computer(s)");
                } catch (InterruptedException e) {
                    throw new AssertionError(e); // since we confirmed that the future is already done
                } catch (ExecutionException e) {
                    LOGGER.log(Level.WARNING, "Provisioned slave "+f.displayName+" failed to launch",e.getCause());
                } catch (IOException e) {
View Full Code Here

    @Argument(metaVar="NAME",usage="Name of the job to create")
    public String name;

    protected int run() throws Exception {
        Hudson h = Hudson.getInstance();
        h.checkPermission(Item.CREATE);

        if (h.getItem(name)!=null) {
            stderr.println("Job '"+name+"' already exists");
            return -1;
        }

        h.createProjectFromXML(name,stdin);
        return 0;
    }
View Full Code Here

    @Option(name = "-fs", aliases = {"--force-save"}, usage = "Force saving the destination job in order to enable build functionality.")
    public boolean forceSave;

    protected int run() throws Exception {
        Hudson h = Hudson.getInstance();
        h.checkPermission(Item.CREATE);

        if (h.getItem(dst)!=null) {
            stderr.println("Job '"+dst+"' already exists");
            return -1;
        }
       
        h.copy(src,dst);
        Job newJob = (Job)Hudson.getInstance().getItem(dst);
        if (forceSave && null != newJob) {
            newJob.save();
        }
        return 0;
View Full Code Here

            return RECURRENCEPERIOD;
        }

        @Override
        protected void doRun() {
            Hudson h = Hudson.getInstance();
            h.overallNodeProvisioner.update();
            for( Label l : h.getLabels() )
                l.nodeProvisioner.update();
        }
View Full Code Here

    /**
     * Figures out a string that identifies this instance of Hudson.
     */
    public String getId() {
        Hudson h = Hudson.getInstance();

        // in servlet 2.5, we can get the context path
        String contextPath="";
        try {
            Method m = ServletContext.class.getMethod("getContextPath");
            contextPath=" contextPath=\""+m.invoke(h.servletContext)+"\"";
        } catch (Exception e) {
            // maybe running with Servlet 2.4
        }

        return h.hashCode()+contextPath+" at "+ManagementFactory.getRuntimeMXBean().getName();
    }
View Full Code Here

    /**
     * Accepts the update to the node configuration.
     */
    public void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException {
        final Hudson app = Hudson.getInstance();

        app.checkPermission(Hudson.ADMINISTER);

        properties.rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors());
        updateTransientActions();
        save();

View Full Code Here

    /**
     * Called from the confirmation screen to actually initiate the migration.
     */
    public void doStart(StaplerRequest req, StaplerResponse rsp, @QueryParameter String username, @QueryParameter String password) throws ServletException, IOException {
        requirePOST();
        Hudson hudson = Hudson.getInstance();
        hudson.checkPermission(Hudson.ADMINISTER);

        final String datasetName;
        ByteArrayOutputStream log = new ByteArrayOutputStream();
        StreamTaskListener listener = new StreamTaskListener(log);
        try {
View Full Code Here

     * Because servlet containers generally don't specify the ordering of the initialization
     * (and different implementations indeed do this differently --- See HUDSON-3878),
     * we cannot use Hudson to the CrumbIssuer into CrumbFilter eagerly.
     */
    public CrumbIssuer getCrumbIssuer() {
        Hudson h = Hudson.getInstance();
        if(h==null)     return null;    // before Hudson is initialized?
        return h.getCrumbIssuer();
    }
View Full Code Here

TOP

Related Classes of hudson.model.Hudson

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.