Package jenkins.model

Examples of jenkins.model.Jenkins


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

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


* @author Kohsuke Kawaguchi
*/
@Extension
public class TooManyJobsButNoView extends AdministrativeMonitor {
    public boolean isActivated() {
        Jenkins h = Jenkins.getInstance();
        return h.getViews().size()==1 && h.getItemMap().size()> THRESHOLD;
    }
View Full Code Here

        }
    }

    @Override
    public void restart() throws IOException, InterruptedException {
        Jenkins h = Jenkins.getInstance();
        if (h != null)
            h.cleanUp();

        // close all files upon exec, except stdin, stdout, and stderr
        int sz = LIBC.getdtablesize();
        for(int i=3; i<sz; i++) {
            int flags = LIBC.fcntl(i, F_GETFD);
View Full Code Here

    /**
     * In SMF managed environment, just commit a suicide and the service will be restarted by SMF.
     */
    @Override
    public void restart() throws IOException, InterruptedException {
        Jenkins h = Jenkins.getInstance();
        if (h != null)
            h.cleanUp();
        System.exit(0);
    }
View Full Code Here

        /**
         * If there's no distributed build set up, it's pointless to provide this axis.
         */
        @Override
        public boolean isInstantiable() {
            Jenkins h = Jenkins.getInstance();
            return !h.getNodes().isEmpty() || !h.clouds.isEmpty();
        }
View Full Code Here

        }

        @Override
        public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
            // for compatibility reasons, the actual value is stored in Jenkins
            Jenkins j = Jenkins.getInstance();

            if (json.has("myViewsTabBar")) {
                j.setMyViewsTabBar(req.bindJSON(MyViewsTabBar.class,json.getJSONObject("myViewsTabBar")));
            } else {
                j.setMyViewsTabBar(new DefaultMyViewsTabBar());
            }

            return true;
        }
View Full Code Here

@Extension(ordinal=300)
public class GlobalDefaultViewConfiguration extends GlobalConfiguration {
    @Override
    public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
        // for compatibility reasons, the actual value is stored in Jenkins
        Jenkins j = Jenkins.getInstance();
        j.setPrimaryView(json.has("primaryView") ? j.getView(json.getString("primaryView")) : j.getViews().iterator().next());
        return true;
    }
View Full Code Here

        }

        @Override
        public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
            // for compatibility reasons, the actual value is stored in Jenkins
            Jenkins j = Jenkins.getInstance();

            if (json.has("viewsTabBar")) {
                j.setViewsTabBar(req.bindJSON(ViewsTabBar.class,json.getJSONObject("viewsTabBar")));
            } else {
                j.setViewsTabBar(new DefaultViewsTabBar());
            }

            return true;
        }
View Full Code Here

    }

    private static Future previousSynchronousPolling;

    public static void checkTriggers(final Calendar cal) {
        Jenkins inst = Jenkins.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

    @Option(name="-deploy",usage="Deploy plugins right away without postponing them until the reboot.")
    public boolean dynamicLoad;

    protected int run() throws Exception {
        Jenkins h = Jenkins.getInstance();
        h.checkPermission(Jenkins.ADMINISTER);
        PluginManager pm = h.getPluginManager();

        for (String source : sources) {
            // is this a file?
            if (channel!=null) {
                FilePath f = new FilePath(channel, source);
                if (f.exists()) {
                    stdout.println(Messages.InstallPluginCommand_InstallingPluginFromLocalFile(f));
                    if (name==null)
                        name = f.getBaseName();
                    f.copyTo(getTargetFilePath());
                    if (dynamicLoad)
                        pm.dynamicLoad(getTargetFile());
                    continue;
                }
            }

            // is this an URL?
            try {
                URL u = new URL(source);
                stdout.println(Messages.InstallPluginCommand_InstallingPluginFromUrl(u));
                if (name==null) {
                    name = u.getPath();
                    name = name.substring(name.lastIndexOf('/')+1);
                    name = name.substring(name.lastIndexOf('\\')+1);
                    int idx = name.lastIndexOf('.');
                    if (idx>0name = name.substring(0,idx);
                }
                getTargetFilePath().copyFrom(u);
                if (dynamicLoad)
                    pm.dynamicLoad(getTargetFile());
                continue;
            } catch (MalformedURLException e) {
                // not an URL
            }

            // is this a plugin the update center?
            UpdateSite.Plugin p = h.getUpdateCenter().getPlugin(source);
            if (p!=null) {
                stdout.println(Messages.InstallPluginCommand_InstallingFromUpdateCenter(source));
                Throwable e = p.deploy(dynamicLoad).get().getError();
                if (e!=null)
                    throw new IOException2("Failed to install plugin "+source,e);
                continue;
            }

            stdout.println(Messages.InstallPluginCommand_NotAValidSourceName(source));

            if (!source.contains(".") && !source.contains(":") && !source.contains("/") && !source.contains("\\")) {
                // looks like a short plugin name. Why did we fail to find it in the update center?
                if (h.getUpdateCenter().getSites().isEmpty()) {
                    stdout.println(Messages.InstallPluginCommand_NoUpdateCenterDefined());
                } else {
                    Set<String> candidates = new HashSet<String>();
                    for (UpdateSite s : h.getUpdateCenter().getSites()) {
                        Data dt = s.getData();
                        if (dt==null)
                            stdout.println(Messages.InstallPluginCommand_NoUpdateDataRetrieved(s.getUrl()));
                        else
                            candidates.addAll(dt.plugins.keySet());
                    }
                    stdout.println(Messages.InstallPluginCommand_DidYouMean(source,EditDistance.findNearest(source,candidates)));
                }
            }

            return 1;
        }

        if (restart)
            h.restart();
        return 0; // all success
    }
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.