Package jenkins.model

Examples of jenkins.model.Jenkins


        public String getDisplayName() {
            return "Groovy CPS DSL";
        }

        public FormValidation doCheckScript(@QueryParameter String value, @QueryParameter boolean sandbox) {
            Jenkins j = Jenkins.getInstance();
            if (j == null) {
                return FormValidation.ok();
            }
            try {
                new CpsGroovyShell(null).getClassLoader().parseClass(value);
View Full Code Here


        @Restricted(DoNotUse.class) // from config.jelly
        public HttpResponse doGenerateSnippet(StaplerRequest req, @QueryParameter String json) throws Exception {
            // TODO is there not an easier way to do this?
            JSONObject jsonO = JSONObject.fromObject(json);
            Jenkins j = Jenkins.getInstance();
            if (j == null) {
                throw new IllegalStateException("Jenkins is not running");
            }
            Class<?> c = j.getPluginManager().uberClassLoader.loadClass(jsonO.getString("stapler-class"));
            Object o;
            try {
                o = req.bindJSON(c, jsonO);
            } catch (RuntimeException x) { // e.g. IllegalArgumentException
                return HttpResponses.plainText(Functions.printThrowable(x));
View Full Code Here

        setActions(Collections.<Action>emptyList());
    }

    public StepDescriptor getDescriptor() {
        if (descriptor == null) {
            Jenkins j = Jenkins.getInstance();
            if (j != null) {
                descriptor = (StepDescriptor) j.getDescriptor(descriptorId);
            }
        }
        return descriptor;
    }
View Full Code Here

    @SuppressWarnings({"unchecked", "rawtypes"}) // cannot get from ParameterizedJob back to ParameterizedJobMixIn trivially
    @Override
    public boolean start() throws Exception {
        String job = step.getJob();
        listener.getLogger().println("Starting building project: " + job);
        Jenkins jenkins = Jenkins.getInstance();
        if (jenkins == null) {
            throw new IllegalStateException("Jenkins is not running");
        }
        final ParameterizedJobMixIn.ParameterizedJob project = jenkins.getItem(job, invokingRun.getParent(), ParameterizedJobMixIn.ParameterizedJob.class);
        if (project == null) {
            throw new AbortException("No parameterized job named " + job + " found");
        }
        node.addAction(new LabelAction(Messages.BuildTriggerStepExecution_building_(project.getFullDisplayName())));
        List<Action> actions = new ArrayList<Action>();
View Full Code Here

        return false;
    }

    @Override
    public void stop(Throwable cause) {
        Jenkins jenkins = Jenkins.getInstance();
        if (jenkins == null) {
            return;
        }

        Queue q = jenkins.getQueue();

        // if the build is still in the queue, abort it.
        // BuildTriggerListener will report the failure, so this method shouldn't call getContext().onFailure()
        for (Queue.Item i : q.getItems()) {
            BuildTriggerAction bta = i.getAction(BuildTriggerAction.class);
            if (bta!=null && bta.getStepContext().equals(getContext())) {
                q.cancel(i);
            }
        }

        // if there's any in-progress build already, abort that.
        // when the build is actually aborted, BuildTriggerListener will take notice and report the failure,
        // so this method shouldn't call getContext().onFailure()
        for (Computer c : jenkins.getComputers()) {
            for (Executor e : c.getExecutors()) {
                Queue.Executable exec = e.getCurrentExecutable();
                if (exec instanceof Run) {
                    Run<?,?> b = (Run) exec;
View Full Code Here

        // TODO
        throw new UnsupportedOperationException();
    }

    private static XmlFile getConfigFile() throws IOException {
        Jenkins j = Jenkins.getInstance();
        if (j == null) {
            throw new IOException("Jenkins is not running");
        }
        return new XmlFile(new File(j.getRootDir(), StageStep.class.getName() + ".xml"));
    }
View Full Code Here

    }

    @Override public ListenableFuture<?> rehydrate() {
        return new TryRepeatedly<WorkspaceList.Lease>(1) {
            @Override protected WorkspaceList.Lease tryResolve() throws InterruptedException {
                Jenkins j = Jenkins.getInstance();
                if (j == null) {
                    return null;
                }
                Computer c = j.getComputer(slave);
                if (c == null) {
                    return null;
                }
                VirtualChannel ch = c.getChannel();
                if (ch == null) {
View Full Code Here

    @Override
    public ListenableFuture<Computer> rehydrate() {
        return new TryRepeatedly<Computer>(1) {
            @Override
            protected Computer tryResolve() {
                Jenkins j = Jenkins.getInstance();
                if (j == null) {
                    return null;
                }
                return j.getComputer(slave);
            }
        };
    }
View Full Code Here

    @Override
    public ListenableFuture<FilePath> rehydrate() {
        return new TryRepeatedly<FilePath>(1) {
            @Override
            protected FilePath tryResolve() {
                Jenkins j = Jenkins.getInstance();
                if (j == null) {
                    return null;
                }
                Computer c = j.getComputer(slave);
                if (c == null) {
                    return null;
                }
                VirtualChannel ch = c.getChannel();
                if (ch == null) return null;
View Full Code Here

            d.configureShell(execution,this);
        }
    }

    private static ClassLoader makeClassLoader() {
        Jenkins j = Jenkins.getInstance();
        ClassLoader cl = j != null ? j.getPluginManager().uberClassLoader : CpsGroovyShell.class.getClassLoader();
        return GroovySandbox.createSecureClassLoader(cl);
    }
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.