当前位置: 首页>>代码示例>>Java>>正文


Java Result类代码示例

本文整理汇总了Java中hudson.model.Result的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Result类属于hudson.model包,在下文中一共展示了Result类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: junitResultArchiver

import hudson.model.Result; //导入依赖的package包/类
@Test public void junitResultArchiver() throws Exception {
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
    p.setDefinition(new CpsFlowDefinition(
              "node {\n"
            + "    writeFile text: '''<testsuite name='a'><testcase name='a1'/><testcase name='a2'><error>a2 failed</error></testcase></testsuite>''', file: 'a.xml'\n"
            + "    writeFile text: '''<testsuite name='b'><testcase name='b1'/><testcase name='b2'/></testsuite>''', file: 'b.xml'\n"
            + "    junit '*.xml'\n"
            + "}", true));
    WorkflowRun b = r.assertBuildStatus(Result.UNSTABLE, p.scheduleBuild2(0).get());
    TestResultAction a = b.getAction(TestResultAction.class);
    assertNotNull(a);
    assertEquals(4, a.getTotalCount());
    assertEquals(1, a.getFailCount());
    List<FlowNode> coreStepNodes = new DepthFirstScanner().filteredNodes(b.getExecution(), new NodeStepTypePredicate("step"));
    assertThat(coreStepNodes, Matchers.hasSize(1));
    assertEquals("*.xml", ArgumentsAction.getStepArgumentsAsString(coreStepNodes.get(0)));
}
 
开发者ID:10000TB,项目名称:Jenkins-Plugin-Examples,代码行数:18,代码来源:CoreStepTest.java

示例2: isRelevant

import hudson.model.Result; //导入依赖的package包/类
public static boolean isRelevant(OTCNotifier notifier, String phase, Result result){
    boolean onStarted;
    boolean onCompleted;
    boolean onFinalized;
    boolean failureOnly;

    //Make sure OTC Notifier was found in the publisherList
    if(notifier != null){
        onStarted = notifier.getOnStarted();
        onCompleted = notifier.getOnCompleted();
        onFinalized = notifier.getOnFinalized();
        failureOnly = notifier.getFailureOnly();

        if(onStarted && "STARTED".equals(phase) || onCompleted && "COMPLETED".equals(phase)
                || onFinalized && "FINALIZED".equals(phase)){//check selections
            if(failureOnly && result != null && result.equals(Result.FAILURE) || !failureOnly){//check failureOnly
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:IBM,项目名称:ibm-cloud-devops,代码行数:24,代码来源:EventHandler.java

示例3: onFailure

import hudson.model.Result; //导入依赖的package包/类
@Override public void onFailure(StepContext context, Throwable t) {
    try {
        TaskListener listener = context.get(TaskListener.class);
        Result r = Result.FAILURE;
        if (t instanceof AbortException) {
            listener.error(t.getMessage());
        } else if (t instanceof FlowInterruptedException) {
            FlowInterruptedException fie = (FlowInterruptedException) t;
            fie.handle(context.get(Run.class), listener);
            r = fie.getResult();
        } else {
            listener.getLogger().println(Functions.printThrowable(t).trim()); // TODO 2.43+ use Functions.printStackTrace
        }
        context.get(Run.class).setResult(r);
        context.onSuccess(null);
    } catch (Exception x) {
        context.onFailure(x);
    }
}
 
开发者ID:10000TB,项目名称:Jenkins-Plugin-Examples,代码行数:20,代码来源:CatchErrorStep.java

示例4: failure

import hudson.model.Result; //导入依赖的package包/类
@Test public void failure() {
    story.addStep(new Statement() {
        @Override public void evaluate() throws Throwable {
            WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "p");
            p.setDefinition(new CpsFlowDefinition("waitUntil {semaphore 'wait'}", true));
            WorkflowRun b = p.scheduleBuild2(0).waitForStart();
            SemaphoreStep.waitForStart("wait/1", b);
            SemaphoreStep.success("wait/1", false);
            SemaphoreStep.waitForStart("wait/2", b);
            String message = "broken condition";
            SemaphoreStep.failure("wait/2", new AbortException(message));
            // TODO the following fails (missing message) when run as part of whole suite, but not standalone: story.j.assertLogContains(message, story.j.assertBuildStatus(Result.FAILURE, story.j.waitForCompletion(b)));
            story.j.waitForCompletion(b);
            story.j.assertBuildStatus(Result.FAILURE, b);
            story.j.assertLogContains(message, b); // TODO observed to flake on windows-8-2.32.3: see two `semaphore`s and a “Will try again after 0.25 sec” but no such message
        }
    });
}
 
开发者ID:10000TB,项目名称:Jenkins-Plugin-Examples,代码行数:19,代码来源:WaitForConditionStepTest.java

示例5: abortShouldNotRetry

import hudson.model.Result; //导入依赖的package包/类
@Issue("JENKINS-41276")
@Test
public void abortShouldNotRetry() throws Exception {
    r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
    p.setDefinition(new CpsFlowDefinition(
            "int count = 0; retry(3) { echo 'trying '+(count++); semaphore 'start'; echo 'NotHere' } echo 'NotHere'", true));
    final WorkflowRun b = p.scheduleBuild2(0).waitForStart();
    SemaphoreStep.waitForStart("start/1", b);
    ACL.impersonate(User.get("dev").impersonate(), new Runnable() {
        @Override public void run() {
            b.getExecutor().doStop();
        }
    });
    r.assertBuildStatus(Result.ABORTED, r.waitForCompletion(b));
    r.assertLogContains("trying 0", b);
    r.assertLogContains("Aborted by dev", b);
    r.assertLogNotContains("trying 1", b);
    r.assertLogNotContains("trying 2", b);
    r.assertLogNotContains("NotHere", b);

}
 
开发者ID:10000TB,项目名称:Jenkins-Plugin-Examples,代码行数:23,代码来源:RetryStepTest.java

示例6: toolWithoutSymbol

import hudson.model.Result; //导入依赖的package包/类
@Test public void toolWithoutSymbol() throws Exception {
    File toolHome = folder.newFolder("mockTools");
    MockToolWithoutSymbol tool = new MockToolWithoutSymbol("mock-tool-without-symbol", toolHome.getAbsolutePath(), JenkinsRule.NO_PROPERTIES);
    Jenkins.getInstance().getDescriptorByType(MockToolWithoutSymbol.MockToolWithoutSymbolDescriptor.class).setInstallations(tool);

    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
    p.setDefinition(new CpsFlowDefinition("node {def home = tool name: '" + tool.getName() + "', type: 'mockToolWithoutSymbol'}",
            true));

    r.assertLogContains("No mockToolWithoutSymbol named mock-tool-without-symbol found",
            r.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0)));

    p.setDefinition(new CpsFlowDefinition("node {def home = tool name: '" + tool.getName() + "', type: '" + MockToolWithoutSymbol.class.getName() + "'\n"
            + "echo \"${home}\"}",
            true));
    r.assertLogContains(toolHome.getAbsolutePath(),
            r.assertBuildStatusSuccess(p.scheduleBuild2(0)));
}
 
开发者ID:10000TB,项目名称:Jenkins-Plugin-Examples,代码行数:19,代码来源:ToolStepTest.java

示例7: specialStatus

import hudson.model.Result; //导入依赖的package包/类
@Test public void specialStatus() throws Exception {
    User.get("smrt");
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
    p.setDefinition(new CpsFlowDefinition(
            "catchError {\n" +
            "  semaphore 'specialStatus'\n" +
            "}", true));
    SemaphoreStep.failure("specialStatus/1", new FlowInterruptedException(Result.UNSTABLE, new CauseOfInterruption.UserInterruption("smrt")));
    WorkflowRun b = p.scheduleBuild2(0).get();
    r.assertLogContains("smrt", r.assertBuildStatus(Result.UNSTABLE, b));
    /* TODO fixing this is trickier since CpsFlowExecution.setResult does not implement a public method, and anyway CatchErrorStep in its current location could not refer to FlowExecution:
    List<FlowNode> heads = b.getExecution().getCurrentHeads();
    assertEquals(1, heads.size());
    assertEquals(Result.UNSTABLE, ((FlowEndNode) heads.get(0)).getResult());
    */
}
 
开发者ID:10000TB,项目名称:Jenkins-Plugin-Examples,代码行数:17,代码来源:CatchErrorStepTest.java

示例8: downstreamJobTriggerByRestrictedUser

import hudson.model.Result; //导入依赖的package包/类
@Test
public void downstreamJobTriggerByRestrictedUser() throws Exception {
    String allowedUsername = "foo";
    UserSelector selector = new UserSelector(allowedUsername);
    JobRestriction restriction = new StartedByUserRestriction(singletonList(selector), false, false, false);
    setUpDiskPoolRestriction(restriction);

    authenticate(allowedUsername);
    WorkflowRun upstreamRun = createWorkflowJobAndRun();

    j.assertBuildStatusSuccess(upstreamRun);
    j.assertLogContains(format("Selected Disk ID '%s' from the Disk Pool ID '%s'", DISK_ID_ONE, DISK_POOL_ID), upstreamRun);

    String notAllowedUsername = "bar";
    authenticate(notAllowedUsername);

    WorkflowJob downstreamJob = j.jenkins.createProject(WorkflowJob.class, randomAlphanumeric(7));
    downstreamJob.setDefinition(new CpsFlowDefinition(format("" +
            "def run = selectRun '%s' \n" +
            "exwsAllocate selectedRun: run", upstreamRun.getParent().getFullName())));
    WorkflowRun downstreamRun = downstreamJob.scheduleBuild2(0, new CauseAction(new Cause.UserIdCause())).get();

    j.assertBuildStatus(Result.FAILURE, downstreamRun);
    j.assertLogContains(format("Disk Pool identified by '%s' is not accessible due to the applied Disk Pool restriction: Started By User", DISK_POOL_ID), downstreamRun);
}
 
开发者ID:jenkinsci,项目名称:external-workspace-manager-plugin,代码行数:26,代码来源:DiskPoolRestrictionTest.java

示例9: notAllowedGroup

import hudson.model.Result; //导入依赖的package包/类
@Test
public void notAllowedGroup() throws Exception {
    String username = "foobar";
    String group = "allowed";

    GroupSelector groupSelector = new GroupSelector("not-allowed-group");
    JobRestriction restriction = new StartedByMemberOfGroupRestriction(singletonList(groupSelector), false);
    setUpDiskPoolRestriction(restriction);

    JenkinsRule.DummySecurityRealm securityRealm = j.createDummySecurityRealm();
    securityRealm.addGroups(username, group);
    j.jenkins.setSecurityRealm(securityRealm);

    authenticate(username);
    WorkflowRun run = createWorkflowJobAndRun();

    j.assertBuildStatus(Result.FAILURE, run);
    j.assertLogContains(format("Disk Pool identified by '%s' is not accessible due to the applied Disk Pool restriction: Started By member of group", DISK_POOL_ID), run);
}
 
开发者ID:jenkinsci,项目名称:external-workspace-manager-plugin,代码行数:20,代码来源:DiskPoolRestrictionTest.java

示例10: diskHasNotEnoughUsableSpace

import hudson.model.Result; //导入依赖的package包/类
@Test
@Parameters({"fastestWriteSpeed(estimatedWorkspaceSize: 300)",
             "[$class: 'FastestWriteSpeedStrategy'\\, estimatedWorkspaceSize: 300]"})
public void diskHasNotEnoughUsableSpace(String strategy) throws Exception {
    // The Disk mounting point parameter isn't an actual mount.
    // Therefore, the disk's usable space will be 0, and the job will fail as expected
    Disk disk = new Disk("disk", null, "not-an-actual-mounting-point", null, null);
    DiskPool diskPool = TestUtil.createDiskPool(disk);
    TestUtil.setUpDiskPools(j.jenkins, diskPool);
    long estimatedWorkspaceSize = 300;

    WorkflowRun run = TestUtil.createWorkflowJobAndRun(j.jenkins, format("" +
            "exwsAllocate diskPoolId: '%s', " +
            " strategy: %s", diskPool.getDiskPoolId(), strategy));

    j.assertBuildStatus(Result.FAILURE, run);
    j.assertLogContains(format("Using Disk allocation strategy: '%s'", new FastestWriteSpeedStrategy().getDescriptor().getDisplayName()), run);
    j.assertLogContains(format("Couldn't find any Disk with at least %s MB usable space", estimatedWorkspaceSize), run);
}
 
开发者ID:jenkinsci,项目名称:external-workspace-manager-plugin,代码行数:20,代码来源:DiskAllocationStrategyTest.java

示例11: runToBuildPhase

import hudson.model.Result; //导入依赖的package包/类
private String runToBuildPhase(Run run) {
	if (run != null && !run.hasntStartedYet()) {
		if (run.isBuilding()) {
			return BuildPhases.RUNNING;
		} else {
			Result result = run.getResult();
			if (result != null) {
				if (result.equals(Result.SUCCESS)) {
					return BuildPhases.COMPLETE;
				} else if (result.equals(Result.ABORTED)) {
					return BuildPhases.CANCELLED;
				} else if (result.equals(Result.FAILURE)) {
					return BuildPhases.FAILED;
				} else if (result.equals(Result.UNSTABLE)) {
					return BuildPhases.FAILED;
				} else {
					return BuildPhases.PENDING;
				}
			}
		}
	}
	return BuildPhases.NEW;
}
 
开发者ID:jenkinsci,项目名称:openshift-sync-plugin,代码行数:24,代码来源:BuildSyncRunListener.java

示例12: testBuildThenWaitThenSuccess

import hudson.model.Result; //导入依赖的package包/类
@Test
public void testBuildThenWaitThenSuccess() throws Exception {
    setUpBuildEnvironment();
    Build inProgress = new Build().withBuildStatus(StatusType.IN_PROGRESS).withStartTime(new Date(1));
    Build succeeded = new Build().withBuildStatus(StatusType.SUCCEEDED.toString().toUpperCase()).withStartTime(new Date(2));
    when(mockClient.batchGetBuilds(any(BatchGetBuildsRequest.class))).thenReturn(
            new BatchGetBuildsResult().withBuilds(inProgress),
            new BatchGetBuildsResult().withBuilds(inProgress),
            new BatchGetBuildsResult().withBuilds(succeeded));
    CodeBuilder test = createDefaultCodeBuilder();
    ArgumentCaptor<Result> savedResult = ArgumentCaptor.forClass(Result.class);

    test.perform(build, ws, launcher, listener);

    verify(build).setResult(savedResult.capture());
    assertEquals(savedResult.getValue(), Result.SUCCESS);
}
 
开发者ID:awslabs,项目名称:aws-codebuild-jenkins-plugin,代码行数:18,代码来源:CodeBuilderEndToEndPerformTest.java

示例13: testBuildThenWaitThenFails

import hudson.model.Result; //导入依赖的package包/类
@Test
public void testBuildThenWaitThenFails() throws Exception {
    setUpBuildEnvironment();
    Build inProgress = new Build().withBuildStatus(StatusType.IN_PROGRESS).withStartTime(new Date(1));
    Build failed = new Build().withBuildStatus(StatusType.FAILED).withStartTime(new Date(2));
    when(mockClient.batchGetBuilds(any(BatchGetBuildsRequest.class))).thenReturn(
            new BatchGetBuildsResult().withBuilds(inProgress),
            new BatchGetBuildsResult().withBuilds(inProgress),
            new BatchGetBuildsResult().withBuilds(failed));
    CodeBuilder test = createDefaultCodeBuilder();
    ArgumentCaptor<Result> savedResult = ArgumentCaptor.forClass(Result.class);

    test.perform(build, ws, launcher, listener);

    verify(build).setResult(savedResult.capture());
    assertEquals(savedResult.getValue(), Result.FAILURE);
}
 
开发者ID:awslabs,项目名称:aws-codebuild-jenkins-plugin,代码行数:18,代码来源:CodeBuilderEndToEndPerformTest.java

示例14: perform

import hudson.model.Result; //导入依赖的package包/类
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
        throws InterruptedException, IOException {

    try {
        GoogleRobotCredentials credentials = GoogleRobotCredentials.getById(getCredentialsId());
        GoogleDriveManager driveManager = new GoogleDriveManager(authorize(credentials));

        String pattern = Util.replaceMacro(getPattern(), build.getEnvironment(listener));
        String workspace = build.getWorkspace().getRemote();
        String[] filesToUpload = listFiles(workspace, pattern);
        for (String file : filesToUpload) {
            listener.getLogger().println("Uploading file: " + file);
            driveManager.store(file, getDriveLocation());
        }
    } catch (GeneralSecurityException e) {
        build.setResult(Result.FAILURE);
        return false;
    }
    return true;
}
 
开发者ID:nassendelft,项目名称:jenkins-plugin-google-driver-uploader,代码行数:22,代码来源:GoogleDriveUploader.java

示例15: run

import hudson.model.Result; //导入依赖的package包/类
@Override
protected Void run() throws Exception {
    if (step.getAppid() != null && !step.getAppid().equals("")) {
        listener.getLogger().println("[Marathon] DEPRECATION WARNING: This configuration is using \"appid\" instead of \"id\". Please update this configuration.");
        step.setId(step.getAppid());
    }

    try {
        MarathonBuilder
                .getBuilder(step)
                .setEnvVars(envVars)
                .setWorkspace(ws)
                .read(step.filename)
                .build()
                .toFile()
                .update();
    } catch (MarathonException | MarathonFileInvalidException | MarathonFileMissingException me) {
        final String errorMsg = String.format("[Marathon] %s", me.getMessage());
        listener.error(errorMsg);
        run.setResult(Result.FAILURE);
    }

    return null;
}
 
开发者ID:jenkinsci,项目名称:marathon-plugin,代码行数:25,代码来源:MarathonStep.java


注:本文中的hudson.model.Result类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。