Package hudson.model

Examples of hudson.model.Job


    @Test
    @PrepareForTest(User.class)
    public void testIsAuthorUserNull() throws Exception {
        mockStatic(User.class);
        expect(User.current()).andReturn(null);
        Job job = createMock(FreeStyleProject.class);
        replay(User.class, job);
        boolean result = Functions.isAuthor(job);
        verify(User.class, job);
        assertFalse(result);
    }
View Full Code Here


        return list(null);
    }

    public static MetaProject find(final UUID id) {
        checkNotNull(id);
        Job job = JobUuid.find(id);
        if (job instanceof AbstractProject) {
            return new MetaProject((AbstractProject)job);
        }
        return null;
    }
View Full Code Here

     * Converts the Hudson build status to CruiseControl build status,
     * which is either Success, Failure, Exception, or Unknown.
     */
    public static String toCCStatus(Item i) {
        if (i instanceof Job) {
            Job j = (Job) i;
            switch (j.getIconColor().noAnime()) {
            case ABORTED:
            case RED:
            case YELLOW:
                return "Failure";
            case BLUE:
View Full Code Here

            String[] envs = c.channel.call(new GetCharacteristicEnvironmentVariables());

            if (envs[0]==null || envs[1]==null)
                throw new CmdLineException("This CLI command works only when invoked from inside a build");

            Job j = Hudson.getInstance().getItemByFullName(envs[0],Job.class);
            if (j==null)    throw new CmdLineException("No such job: "+envs[0]);

            try {
                Run r = j.getBuildByNumber(Integer.parseInt(envs[1]));
                if (r==null)    throw new CmdLineException("No such build #"+envs[1]+" in "+envs[0]);
                return r;
            } catch (NumberFormatException e) {
                throw new CmdLineException("Invalid build number: "+envs[1]);
            }
View Full Code Here

            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

        if (null != cascadingCandidate && CollectionUtils.isNotEmpty(cascadingChildren)) {
            if (cascadingChildren.contains(cascadingCandidate.getName())) {
                return true;
            }
            for (String childName : cascadingChildren) {
                Job job = Functions.getItemByName(Hudson.getInstance().getAllItems(Job.class), childName);
                if (null != job && hasCyclicCascadingLink(cascadingCandidate, job.getCascadingChildrenNames())) {
                    return true;
                }
            }
        }
        return false;
View Full Code Here

     * @throws java.io.IOException if cascading project couldn't be saved.
     */
    public static boolean unlinkProjectFromCascadingParents(ICascadingJob cascadingProject, String projectToUnlink)
        throws IOException {
        if (null != cascadingProject && null != projectToUnlink) {
            Job job = Functions.getItemByName(Hudson.getInstance().getAllItems(Job.class), projectToUnlink);
            if (null != job) {
                Set<String> set = new HashSet<String>(job.getCascadingChildrenNames());
                set.add(projectToUnlink);
                return unlinkProjectFromCascadingParents(cascadingProject, set);
            }
        }
        return false;
View Full Code Here

     * @param <T> Item
     * @return list of cascading parents.
     */
    @SuppressWarnings("unchecked")
    public static <T extends Item> List<Job> getCascadingParents(Class<T> type, Job currentJob) {
        Job currentParent = currentJob.getCascadingProject();
        if (type.isInstance(currentParent) && !currentParent.hasPermission(Item.READ)) {
            return Collections.EMPTY_LIST; // user can't see parent so don't let them change it
        }
        List<T> allItems = Hudson.getInstance().getAllItems(type);
        List<Job> result = new ArrayList<Job>(allItems.size());
        for (T item : allItems) {
            Job job = (Job) item;
            if (!StringUtils.equals(currentJob.getName(), job.getName())
                && !hasCyclicCascadingLink(job, currentJob.getCascadingChildrenNames())) {
                result.add(job);
            }
        }
        return result;
View Full Code Here

        }
        property.setValue(trigger);
        Set<String> cascadingChildrenNames = job.getCascadingChildrenNames();
        if (null != cascadingChildrenNames) {
            for (String childName : cascadingChildrenNames) {
                Job childJob = (Job) Hudson.getInstance().getItem(childName);
                if (null != childJob && StringUtils.equals(job.getName(), childJob.getCascadingProjectName())) {
                    TriggerProjectProperty childProperty = CascadingUtil.getTriggerProjectProperty(childJob, key);
                    if (!childProperty.isOverridden()) {
                        setChildrenTrigger(childJob, descriptor, key, req, json);
                    } else if (!childProperty.allowOverrideValue(trigger, childProperty.getValue())) {
                        childProperty.setOverridden(false);
View Full Code Here

        projectProperty.setValue(pdProperties);
        Set<String> cascadingChildrenNames = job.getCascadingChildrenNames();
        //Iterate through cascading children and recursively update property for each child.
        if (null != cascadingChildrenNames) {
            for (String childName : cascadingChildrenNames) {
                Job childJob = (Job) Hudson.getInstance().getItem(childName);
                //Check only direct children in order to avoid deep checking for properties overridden properties.
                if (null != childJob && StringUtils.equals(job.getName(), childJob.getCascadingProjectName())) {
                    CopyOnWriteListProjectProperty childProperty = getCopyOnWriteListProjectProperty(childJob, key);
                    //If child value is equal to parent - mark this value as unmodified.
                    if (!childProperty.allowOverrideValue(childProperty.getValue(), pdProperties)) {
                        childProperty.setOverridden(false);
                    } else if (!childProperty.isOverridden()) {
View Full Code Here

TOP

Related Classes of hudson.model.Job

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.