Package hudson.model

Examples of hudson.model.Job


            String[] envs = c.checkChannel().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 = Jenkins.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


    sscBusiness.synchronizeAllConfigs(ScmSyncConfigurationPlugin.AVAILABLE_STRATEGIES);

        File subModuleConfigFile = new File(getCurrentHudsonRootDirectory() + "/jobs/fakeJob/modules/submodule/config.xml" );

        // Creating fake new item
        Job mockedItem = Mockito.mock(Job.class);
        when(mockedItem.getRootDir()).thenReturn(subModuleConfigFile.getParentFile());

        sscConfigurationSaveableListener.onChange(mockedItem, new XmlFile(subModuleConfigFile));

    verifyCurrentScmContentMatchesHierarchy("expected-scm-hierarchies/JobConfigScmSyncStrategyTest.shouldConfigInSubmodulesNotSynced/");
View Full Code Here

        return writer.toString();
    }

    protected boolean isBuildRunning(Label label) {
        boolean running = false;
        Job job = (Job) Hudson.getInstance().getItem(label.getName());
        if (job != null) {
            Queue.Item item = job.getQueueItem();
            if (item != null)
                running = true;
        }

        return running;
View Full Code Here

        cancelBuild(builderName, null);
    }

    protected Queue.Item getItem(String builderName, String label) {
        try {
            Job job = null;

            if (label != null)
                job = (Job) Hudson.getInstance().getItem(label);

            if (job != null) {
                Queue.Item item = job.getQueueItem();
                if (item != null) {
                    return item;
                }
            } else {
                Queue queue = Hudson.getInstance().getQueue();
View Full Code Here

                }
            };
        }
       
        private String preparePath(String path) {
            Job job = getParent().getRun().getParent();
            SCMTriggerItem s = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job);
            if (s == null) {
                return path;
            }
            for (SCM scm : s.getSCMs()) {
View Full Code Here

    public void testIsAuthorTrue() throws Exception {
        mockStatic(User.class);
        User user = createMock(User.class);
        expect(user.getId()).andReturn(USER);
        expect(User.current()).andReturn(user);
        Job job = createMock(FreeStyleProject.class);
        expect(job.getCreatedBy()).andReturn(USER).times(2);
        replay(User.class, user, job);
        boolean result = Functions.isAuthor(job);
        verify(User.class, user, job);
        assertTrue(result);
    }
View Full Code Here

    public void testIsAuthorFalse() throws Exception {
        mockStatic(User.class);
        User user = createMock(User.class);
        expect(user.getId()).andReturn(USER);
        expect(User.current()).andReturn(user);
        Job job = createMock(FreeStyleProject.class);
        expect(job.getCreatedBy()).andReturn("user").times(2);
        replay(User.class, user, job);
        boolean result = Functions.isAuthor(job);
        verify(User.class, user, job);
        assertFalse(result);
    }
View Full Code Here

    }

    @Test
    @PrepareForTest({Hudson.class, StaplerRequest.class})
    public void testBuildExternalProperties() throws Exception {
        Job job = new FreeStyleProjectMock("job");
        StaplerRequest req = createMock(StaplerRequest.class);
        String javadocArchiverKey = "hudson-tasks-JavadocArchiver";
        JSONObject archiver = new JSONObject();
        archiver.put("javadoc_dir", "dir");
        archiver.put("keep_all", true);
View Full Code Here

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

    public void testIsAuthorUserIdNull() throws Exception {
        mockStatic(User.class);
        User user = createMock(User.class);
        expect(user.getId()).andReturn(null);
        expect(User.current()).andReturn(user);
        Job job = createMock(FreeStyleProject.class);
        expect(job.getCreatedBy()).andReturn(USER).times(2);
        replay(User.class, user, job);
        boolean result = Functions.isAuthor(job);
        verify(User.class, user, job);
        assertFalse(result);
    }
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.