Package jenkins.model

Examples of jenkins.model.Jenkins


    /**
     * Does the opposite of {@link #toNameList(Collection)}.
     */
    public static <T extends Item> List<T> fromNameList(ItemGroup context, String list, Class<T> type) {
        Jenkins hudson = Jenkins.getInstance();

        List<T> r = new ArrayList<T>();
        StringTokenizer tokens = new StringTokenizer(list,",");
        while(tokens.hasMoreTokens()) {
            String fullName = tokens.nextToken().trim();
            T item = hudson.getItem(fullName, context, type);
            if(item!=null)
                r.add(item);
        }
        return r;
    }
View Full Code Here


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

        app.checkPermission(Jenkins.ADMINISTER);

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

View Full Code Here

    /**
     * Figures out a string that identifies this instance of Hudson.
     */
    public String getId() {
        Jenkins h = Jenkins.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

                Map<String,Fingerprint> m = ref.get();
                if(m!=null)
                    return m;
            }

            Jenkins h = Jenkins.getInstance();

            Map<String,Fingerprint> m = new TreeMap<String,Fingerprint>();
            for (Entry<String, String> r : record.entrySet()) {
                try {
                    Fingerprint fp = h._getFingerprint(r.getValue());
                    if(fp!=null)
                        m.put(r.getKey(), fp);
                } catch (IOException e) {
                    logger.log(Level.WARNING,e.getMessage(),e);
                }
View Full Code Here

    /**
     * Gets the encrypted usage stat data to be sent to the Hudson server.
     */
    public String getStatData() throws IOException {
        Jenkins h = Jenkins.getInstance();

        JSONObject o = new JSONObject();
        o.put("stat",1);
        o.put("install", Util.getDigestOf(h.getSecretKey()));
        o.put("version", Jenkins.VERSION);

        List<JSONObject> nodes = new ArrayList<JSONObject>();
        for( Computer c : h.getComputers() ) {
            JSONObject  n = new JSONObject();
            if(c.getNode()==h) {
                n.put("master",true);
                n.put("jvm-vendor", System.getProperty("java.vm.vendor"));
                n.put("jvm-version", System.getProperty("java.version"));
            }
            n.put("executors",c.getNumExecutors());
            DescriptorImpl descriptor = h.getDescriptorByType(DescriptorImpl.class);
            n.put("os", descriptor.get(c));
            nodes.add(n);
        }
        o.put("nodes",nodes);

        List<JSONObject> plugins = new ArrayList<JSONObject>();
        for( PluginWrapper pw : h.getPluginManager().getPlugins() ) {
            if(!pw.isActive())  continue;   // treat disabled plugins as if they are uninstalled
            JSONObject p = new JSONObject();
            p.put("name",pw.getShortName());
            p.put("version",pw.getVersion());
            plugins.add(p);
        }
        o.put("plugins",plugins);

        JSONObject jobs = new JSONObject();
        List<TopLevelItem> items = h.getItems();
        for (TopLevelItemDescriptor d : Items.all()) {
            int cnt=0;
            for (TopLevelItem item : items) {
                if(item.getDescriptor()==d)
                    cnt++;
View Full Code Here

                return;
            }
           
            this.listener = listener;

            Jenkins h = Jenkins.getInstance();
            for (Node n : h.getNodes())
                if (n instanceof Slave) process((Slave)n);

            process(h);
        } finally {
            this.listener = null;
View Full Code Here

    public List<Descriptor> getProblems() {
        return Collections.unmodifiableList(problems);
    }

    private 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",
View Full Code Here

            List<Module> modules = new ArrayList<Module>();
            modules.add(new AbstractModule() {
                @Override
                protected void configure() {
                    Jenkins j = Jenkins.getInstance();
                    bind(Jenkins.class).toInstance(j);
                    bind(PluginManager.class).toInstance(j.getPluginManager());
                }
            });
            modules.add(new SezpozModule(sezpozIndex));

            for (ExtensionComponent<Module> ec : moduleFinder.find(Module.class, Hudson.getInstance())) {
View Full Code Here

            ConsistentHash<Node> hash = new ConsistentHash<Node>(new Hash<Node>() {
                public String hash(Node node) {
                    return node.getNodeName();
                }
            });
            Jenkins h = Jenkins.getInstance();
            hash.add(h, h.getNumExecutors()*100);
            for (Node n : h.getNodes())
                hash.add(n,n.getNumExecutors()*100);

            Label lbl = p.getAssignedLabel();
            for (Node n : hash.list(p.task.getFullDisplayName())) {
                Computer c = n.toComputer();
View Full Code Here

                }

                // if we trust default root CAs, we end up trusting anyone who has a valid certificate,
                // which isn't useful at all
                Set<TrustAnchor> anchors = new HashSet<TrustAnchor>(); // CertificateUtil.getDefaultRootCAs();
                Jenkins j = Jenkins.getInstance();
                for (String cert : (Set<String>) j.servletContext.getResourcePaths("/WEB-INF/update-center-rootCAs")) {
                    if (cert.endsWith(".txt"))  continue;       // skip text files that are meant to be documentation
                    anchors.add(new TrustAnchor((X509Certificate)cf.generateCertificate(j.servletContext.getResourceAsStream(cert)),null));
                }
                File[] cas = new File(j.root, "update-center-rootCAs").listFiles();
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.