hudson.model.Result Java Examples
The following examples show how to use
hudson.model.Result.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TeeStepTest.java From pipeline-utility-steps-plugin with MIT License | 6 votes |
@Test @Issue({"JENKINS-54346", "JENKINS-55505"}) public void closed() throws Exception { rr.then(r -> { r.createSlave("remote", null, null); WorkflowJob p = r.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition( "node('remote') {\n" + " tee('x.log') {\n" + " echo 'first message'\n" + " }\n" + " if (isUnix()) {sh 'rm x.log'} else {bat 'del x.log'}\n" + " writeFile file: 'x.log', text: 'second message'\n" + " echo(/got: ${readFile('x.log').trim().replaceAll('\\\\s+', ' ')}/)\n" + "}", true)); WorkflowRun b = p.scheduleBuild2(0).waitForStart(); r.assertBuildStatus(Result.SUCCESS, r.waitForCompletion(b)); r.assertLogContains("got: second message", b); }); }
Example #2
Source File: CodeBuilderPerformTest.java From aws-codebuild-jenkins-plugin with Apache License 2.0 | 6 votes |
@Test public void testSourceTypeOverrideException() throws Exception { CodeBuilder test = new CodeBuilder("keys", "id123", "host", "60", "a", awsSecretKey, "", "us-east-1", "existingProject", "sourceVersion", "", SourceControlType.ProjectSource.toString(), "", "", GitCloneDepth.One.toString(), BooleanValue.False.toString(), "", "", ArtifactsType.NO_ARTIFACTS.toString(), "", "", "", "", "", BooleanValue.False.toString(), BooleanValue.False.toString(), "", "[{k, v}]", "[{k, p}]", "buildspec.yml", "5", "invalidSourceType", "https://1.0.0.0.86/my_repo", EnvironmentType.LINUX_CONTAINER.toString(), "aws/codebuild/openjdk-8", ComputeType.BUILD_GENERAL1_SMALL.toString(), CacheType.NO_CACHE.toString(), "", LogsConfigStatusType.ENABLED.toString(), "group", "stream", LogsConfigStatusType.ENABLED.toString(), "", "location", "arn:aws:s3:::my_bucket/certificate.pem", "my_service_role", BooleanValue.False.toString(), BooleanValue.False.toString(), BooleanValue.False.toString(), "", "DISABLED", ""); ArgumentCaptor<Result> savedResult = ArgumentCaptor.forClass(Result.class); test.perform(build, ws, launcher, listener, mockStepContext); verify(build).setResult(savedResult.capture()); assertEquals(savedResult.getValue(), Result.FAILURE); assertEquals("Invalid log contents: " + log.toString(), log.toString().contains(CodeBuilderValidation.invalidSourceTypeError), true); CodeBuildResult result = test.getCodeBuildResult(); assertEquals(CodeBuildResult.FAILURE, result.getStatus()); assertTrue(result.getErrorMessage().contains(CodeBuilderValidation.invalidSourceTypeError)); }
Example #3
Source File: PipelineNodeContainerImpl.java From blueocean-plugin with MIT License | 6 votes |
public PipelineNodeContainerImpl(WorkflowRun run, Link parentLink) { this.run = run; this.self = parentLink.rel("nodes"); WorkflowJob job = run.getParent(); NodeGraphBuilder graphBuilder = NodeGraphBuilder.NodeGraphBuilderFactory.getInstance(run); //If build either failed or is in progress then return union with last successful pipeline run if (run.getResult() != Result.SUCCESS && job.getLastSuccessfulBuild() != null && Integer.parseInt(job.getLastSuccessfulBuild().getId()) < Integer.parseInt(run.getId())) { NodeGraphBuilder pastBuildGraph = NodeGraphBuilder.NodeGraphBuilderFactory.getInstance(job.getLastSuccessfulBuild()); this.nodes = graphBuilder.union(pastBuildGraph.getPipelineNodes(), getLink()); } else { this.nodes = graphBuilder.getPipelineNodes(getLink()); } for (BluePipelineNode node : nodes) { nodeMap.put(node.getId(), node); } }
Example #4
Source File: EnvInjectPluginITest.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Make sure that a file pattern containing environment variables correctly matches the expected files. */ @Test public void shouldResolveEnvVariablesInPattern() { FreeStyleProject project = createJavaWarningsFreestyleProject("**/*.${FILE_EXT}"); injectEnvironmentVariables(project, "HELLO_WORLD=hello_test", "FILE_EXT=txt"); createFileWithJavaWarnings("javac.txt", project, 1, 2, 3); createFileWithJavaWarnings("javac.csv", project, 1, 2); AnalysisResult analysisResult = scheduleBuildAndAssertStatus(project, Result.SUCCESS); assertThat(analysisResult).hasTotalSize(3); assertThat(analysisResult.getInfoMessages()).contains(String.format( "Searching for all files in '%s' that match the pattern '**/*.txt'", getWorkspace(project))); assertThat(analysisResult.getInfoMessages()).contains("-> found 1 file"); }
Example #5
Source File: JobActionITest.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Verifies that the aggregation trend chart is visible for a freestyle job at the top, or bottom, or hidden. */ @Test public void shouldShowTrendsAndAggregationFreestyle() { FreeStyleProject project = createFreeStyleProjectWithWorkspaceFiles(ECLIPSE_LOG, CHECKSTYLE_XML); enableWarnings(project, createEclipse(), createCheckStyle()); buildWithResult(project, Result.SUCCESS); Run<?, ?> build = buildWithResult(project, Result.SUCCESS); assertActionProperties(project, build); assertThatCheckstyleAndEclipseChartExist(project, true); assertThatAggregationChartExists(project, true); project = createAggregationJob(TrendChartType.TOOLS_AGGREGATION); assertThatCheckstyleAndEclipseChartExist(project, true); assertThatAggregationChartExists(project, true); project = createAggregationJob(TrendChartType.AGGREGATION_TOOLS); assertThatCheckstyleAndEclipseChartExist(project, true); assertThatAggregationChartExists(project, true); project = createAggregationJob(TrendChartType.TOOLS_ONLY); assertThatCheckstyleAndEclipseChartExist(project, true); assertThatAggregationChartDoesNotExists(project); }
Example #6
Source File: PipelineMavenPluginDaoAbstractTest.java From pipeline-maven-plugin with MIT License | 6 votes |
@Deprecated @Test public void listDownstreamJobs_upstream_pom_triggers_downstream_pipelines() { dao.getOrCreateBuildPrimaryKey("my-upstream-pom-pipeline-1", 1); dao.recordGeneratedArtifact("my-upstream-pom-pipeline-1", 1, "com.mycompany.pom", "parent-pom", "1.0-SNAPSHOT","pom", "1.0-SNAPSHOT", null, false, "pom", null); dao.updateBuildOnCompletion("my-upstream-pom-pipeline-1", 1, Result.SUCCESS.ordinal, System.currentTimeMillis() - 1111, 5); dao.getOrCreateBuildPrimaryKey("my-downstream-pipeline-1", 2); dao.recordParentProject("my-downstream-pipeline-1", 2, "com.mycompany.pom", "parent-pom", "1.0-SNAPSHOT", false); dao.updateBuildOnCompletion("my-downstream-pipeline-1", 2, Result.SUCCESS.ordinal, System.currentTimeMillis() - 555, 5); SqlTestsUtils.dump("select * from JENKINS_BUILD LEFT OUTER JOIN JENKINS_JOB ON JENKINS_BUILD.JOB_ID = JENKINS_JOB.ID", ds, System.out); SqlTestsUtils.dump("select * from MAVEN_ARTIFACT INNER JOIN GENERATED_MAVEN_ARTIFACT ON MAVEN_ARTIFACT.ID = GENERATED_MAVEN_ARTIFACT.ARTIFACT_ID", ds, System.out); SqlTestsUtils.dump("select * from MAVEN_ARTIFACT INNER JOIN MAVEN_PARENT_PROJECT ON MAVEN_ARTIFACT.ID = MAVEN_PARENT_PROJECT.ARTIFACT_ID", ds, System.out); List<String> downstreamJobs = dao.listDownstreamJobs("my-upstream-pom-pipeline-1", 1); assertThat(downstreamJobs, Matchers.containsInAnyOrder("my-downstream-pipeline-1")); System.out.println(downstreamJobs); }
Example #7
Source File: CodeBuilderPerformTest.java From aws-codebuild-jenkins-plugin with Apache License 2.0 | 6 votes |
@Test public void testGetCBClientExcepts() throws Exception { CodeBuilder test = createDefaultCodeBuilder(); String error = "failed to instantiate cb client."; doThrow(new InvalidInputException(error)).when(mockFactory).getCodeBuildClient(); ArgumentCaptor<Result> savedResult = ArgumentCaptor.forClass(Result.class); test.perform(build, ws, launcher, listener, mockStepContext); verify(build).setResult(savedResult.capture()); assertEquals(savedResult.getValue(), Result.FAILURE); assertEquals("Invalid log contents: " + log.toString(), log.toString().contains(error), true); CodeBuildResult result = test.getCodeBuildResult(); assertEquals(CodeBuildResult.FAILURE, result.getStatus()); assertTrue(result.getErrorMessage().contains(error)); }
Example #8
Source File: MarathonStep.java From marathon-plugin with Apache License 2.0 | 6 votes |
@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; }
Example #9
Source File: AWSCodePipelinePublisherTest.java From aws-codepipeline-plugin-for-jenkins with Apache License 2.0 | 6 votes |
@Test public void skipsPutJobResultWhenSkipPutJobFailureFlagIsSetInModel() { // given when(mockBuild.getResult()).thenReturn(Result.FAILURE); model.setActionTypeCategory("Build"); model.setSkipPutJobResult(true); final List<Artifact> outputBuildArtifacts = new ArrayList<>(); outputBuildArtifacts.add(new Artifact()); outputBuildArtifacts.add(new Artifact()); when(mockJobData.getOutputArtifacts()).thenReturn(outputBuildArtifacts); // when assertFalse(publisher.perform(mockBuild, null, null)); // then final InOrder inOrder = inOrder(mockFactory, mockAWS, mockCodePipelineClient); inOrder.verify(mockFactory, never()).getAwsClient(ACCESS_KEY, SECRET_KEY, PROXY_HOST, PROXY_PORT, REGION, PLUGIN_VERSION); inOrder.verify(mockAWS, never()).getCodePipelineClient(); final String expected = String.format( "[AWS CodePipeline Plugin] Skipping PutJobFailureResult call for the job with ID %s", model.getJob().getId()); assertContainsIgnoreCase(expected, outContent.toString()); }
Example #10
Source File: CodeBuilderPerformTest.java From aws-codebuild-jenkins-plugin with Apache License 2.0 | 6 votes |
@Test public void testConfigAllBlank() throws Exception { CodeBuilder test = new CodeBuilder("", "", "", "", "", null, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); ArgumentCaptor<Result> savedResult = ArgumentCaptor.forClass(Result.class); test.perform(build, ws, launcher, listener, mockStepContext); verify(build).setResult(savedResult.capture()); assertEquals(savedResult.getValue(), Result.FAILURE); assertEquals("Invalid log contents: " + log.toString(), log.toString().contains(CodeBuilder.configuredImproperlyError), true); CodeBuildResult result = test.getCodeBuildResult(); assertEquals(CodeBuildResult.FAILURE, result.getStatus()); assertTrue(result.getErrorMessage().contains(CodeBuilder.configuredImproperlyError)); }
Example #11
Source File: CardBuilderTest.java From office-365-connector-plugin with Apache License 2.0 | 6 votes |
@Test public void createCompletedCard_OnFirstFailure_ReturnsCard() { // given Result result = Result.FAILURE; when(run.getResult()).thenReturn(result); // when Card card = cardBuilder.createCompletedCard(Collections.emptyList()); // then assertThat(card.getSections()).hasSize(1); assertThat(card.getThemeColor()).isEqualTo(result.color.getHtmlBaseColor()); Section section = card.getSections().get(0); assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME); }
Example #12
Source File: TelegramBotPublisher.java From telegram-notifications-plugin with MIT License | 6 votes |
@Override public void perform( @Nonnull Run<?, ?> run, @Nonnull FilePath filePath, @Nonnull Launcher launcher, @Nonnull TaskListener taskListener) throws InterruptedException, IOException { Result result = run.getResult(); boolean success = result == Result.SUCCESS && whenSuccess; boolean unstable = result == Result.UNSTABLE && whenUnstable; boolean failed = result == Result.FAILURE && whenFailed; boolean aborted = result == Result.ABORTED && whenAborted; boolean neededToSend = success || unstable || failed || aborted; if (neededToSend) { TelegramBotRunner.getInstance().getBot() .sendMessage(getMessage(), run, filePath, taskListener); } }
Example #13
Source File: CodeBuilderEndToEndPerformTest.java From aws-codebuild-jenkins-plugin with Apache License 2.0 | 6 votes |
@Test public void testBuildThenWaitThenSuccess() throws Exception { 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, mockStepContext); verify(build).setResult(savedResult.capture()); assertEquals(savedResult.getValue(), Result.SUCCESS); CodeBuildResult result = test.getCodeBuildResult(); assertEquals(CodeBuildResult.SUCCESS, result.getStatus()); }
Example #14
Source File: ReadCSVStepTest.java From pipeline-utility-steps-plugin with MIT License | 6 votes |
@Test public void readFileAndText() throws Exception { String file = writeCSV(getCSV()); WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition( "node {\n" + " def recordsString = \"key,value,attr\\na,b,c\\n1,2,3\\n\"\n" + " List<CSVRecord> records = readCSV text: recordsString, file: '" + file + "'\n" + " assert records.size() == 3\n" + " assert records[0].get(0) == 'key'\n" + " assert records[1].get(1) == 'b'\n" + " assert records[2].get(2) == '3'\n" + "}", true)); WorkflowRun run = p.scheduleBuild2(0).get(); j.assertBuildStatus(Result.FAILURE, run); j.assertLogContains(Messages.ReadCSVStepExecution_tooManyArguments("readCSV"), run); }
Example #15
Source File: DockerComputerConnectorTest.java From docker-plugin with MIT License | 6 votes |
protected void should_connect_agent(DockerTemplate template) throws IOException, ExecutionException, InterruptedException, TimeoutException { // FIXME on CI windows nodes don't have Docker4Windows Assume.assumeFalse(SystemUtils.IS_OS_WINDOWS); String dockerHost = SystemUtils.IS_OS_WINDOWS ? "tcp://localhost:2375" : "unix:///var/run/docker.sock"; DockerCloud cloud = new DockerCloud(cloudName, new DockerAPI(new DockerServerEndpoint(dockerHost, null)), Collections.singletonList(template)); j.jenkins.clouds.replaceBy(Collections.singleton(cloud)); final FreeStyleProject project = j.createFreeStyleProject("test-docker-ssh"); project.setAssignedLabel(Label.get(LABEL)); project.getBuildersList().add(new Shell("whoami")); final QueueTaskFuture<FreeStyleBuild> scheduledBuild = project.scheduleBuild2(0); try { final FreeStyleBuild build = scheduledBuild.get(60L, TimeUnit.SECONDS); Assert.assertTrue(build.getResult() == Result.SUCCESS); Assert.assertTrue(build.getLog().contains("jenkins")); } finally { scheduledBuild.cancel(true); } }
Example #16
Source File: SampleIT.java From office-365-connector-plugin with Apache License 2.0 | 6 votes |
@Test public void validateCompletedRequest_OnMultiplyWebhook_SendsSameData() { // given mockResult(Result.FAILURE); Office365ConnectorWebhookNotifier notifier = new Office365ConnectorWebhookNotifier(run, mockListener()); mockProperty(run.getParent(), WebhookBuilder.sampleMultiplyWebhookWithAllStatuses()); // when notifier.sendBuildCompletedNotification(); // then assertThat(workerAnswer.getAllData()).hasSize(2); assertThat(workerAnswer.getAllData().get(0)).isEqualTo(workerAnswer.getAllData().get(1)); assertThat(workerAnswer.getTimes()).isEqualTo(2); }
Example #17
Source File: RemoteApiITest.java From warnings-ng-plugin with MIT License | 6 votes |
/** Verifies that the remote API for the tools aggregation correctly returns the summary. */ @Test public void shouldReturnAggregation() { FreeStyleProject project = createFreeStyleProjectWithWorkspaceFiles("checkstyle1.xml", "checkstyle2.xml"); enableWarnings(project, createCheckstyle("**/checkstyle1*"), configurePattern(new Pmd()), configurePattern(new SpotBugs())); Run<?, ?> build = buildWithResult(project, Result.SUCCESS); JSONWebResponse json = callJsonRemoteApi(build.getUrl() + "warnings-ng/api/json"); JSONObject result = json.getJSONObject(); assertThatJson(result).node("tools").isArray().hasSize(3); JSONArray tools = result.getJSONArray("tools"); assertThatToolsContains(tools, "checkstyle", "CheckStyle Warnings", 3); assertThatToolsContains(tools, "pmd", "PMD Warnings", 0); assertThatToolsContains(tools, "spotbugs", "SpotBugs Warnings", 0); }
Example #18
Source File: GlobalPipelineMavenConfig.java From pipeline-maven-plugin with MIT License | 6 votes |
@Nonnull public Set<Result> getTriggerDownstreamBuildsResultsCriteria() { Set<Result> result = new HashSet<>(5); if (this.triggerDownstreamUponResultSuccess) result.add(Result.SUCCESS); if (this.triggerDownstreamUponResultUnstable) result.add(Result.UNSTABLE); if (this.triggerDownstreamUponResultAborted) result.add(Result.ABORTED); if (this.triggerDownstreamUponResultNotBuilt) result.add(Result.NOT_BUILT); if (this.triggerDownstreamUponResultFailure) result.add(Result.FAILURE); return result; }
Example #19
Source File: GitLabVotePublisher.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
private boolean isSuccessful(Result result) { if (result == Result.SUCCESS) { return true; } else { return false; } }
Example #20
Source File: QualityGateITest.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Tests if the build is considered unstable when its defined threshold for all issues with normal severity is * reached. */ @Test public void shouldBeUnstableWhenUnstableTotalNormalIsReached() { FreeStyleProject project = createFreeStyleProject(); enableAndConfigureCheckstyle(project, recorder -> recorder.setUnstableTotalNormal(2)); runJobTwice(project, Result.UNSTABLE); }
Example #21
Source File: NodesByLabelStepTest.java From pipeline-utility-steps-plugin with MIT License | 5 votes |
@Test public void test_nodes_by_label_count_d_offline() throws Exception { job.setDefinition(new CpsFlowDefinition("nodesByLabel('d')", true)); run = r.assertBuildStatus(Result.SUCCESS, job.scheduleBuild2(0).get()); r.assertLogContains("Could not find any nodes with 'd' label", run); }
Example #22
Source File: PipelineNodeTest.java From blueocean-plugin with MIT License | 5 votes |
@Test public void KyotoNodesFailureTest3() throws Exception { WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1"); job1.setDefinition(new CpsFlowDefinition("pipeline {\n" + " agent any\n" + " stages {\n" + " stage ('Build') {\n" + "steps{\n" + " sh 'echo \"Building\"'\n" + "}\n" + " }\n" + " stage ('Test') {\n" + "steps{\n" + " sh 'echo \"Testing\"'\n" + "}\n" + " }\n" + " stage ('Deploy') {\n" + "steps{\n" + " sh 'echo1 \"Deploying\"'\n" + "}\n" + " }\n" + " }\n" + "}\n", false)); WorkflowRun b1 = job1.scheduleBuild2(0).get(); j.assertBuildStatus(Result.FAILURE, b1); List<Map> nodes = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/", List.class); Assert.assertEquals(3, nodes.size()); Assert.assertEquals("SUCCESS", nodes.get(0).get("result")); Assert.assertEquals("FINISHED", nodes.get(0).get("state")); Assert.assertEquals("SUCCESS", nodes.get(1).get("result")); Assert.assertEquals("FINISHED", nodes.get(1).get("state")); Assert.assertEquals("FAILURE", nodes.get(2).get("result")); Assert.assertEquals("FINISHED", nodes.get(2).get("state")); }
Example #23
Source File: GitHubNotificationPipelineStepTest.java From pipeline-githubnotify-step-plugin with MIT License | 5 votes |
@Test public void buildWithInferWithoutAccountMustFail() throws Exception { GitHubBuilder ghb = PowerMockito.mock(GitHubBuilder.class); PowerMockito.when(ghb.withProxy(Matchers.<Proxy>anyObject())).thenReturn(ghb); PowerMockito.when(ghb.withOAuthToken(anyString(), anyString())).thenReturn(ghb); PowerMockito.whenNew(GitHubBuilder.class).withNoArguments().thenReturn(ghb); GitHub gh = PowerMockito.mock(GitHub.class); PowerMockito.when(ghb.build()).thenReturn(gh); PowerMockito.when(gh.isCredentialValid()).thenReturn(true); GHRepository repo = PowerMockito.mock(GHRepository.class); GHUser user = PowerMockito.mock(GHUser.class); PowerMockito.when(user.getRepository(anyString())).thenReturn(repo); PowerMockito.when(gh.getUser(anyString())).thenReturn(user); PowerMockito.when((repo.getCommit(anyString()))).thenReturn(null); Credentials dummy = new DummyCredentials(CredentialsScope.GLOBAL, "user", "password"); SystemCredentialsProvider.getInstance().getCredentials().add(dummy); WorkflowJob p = jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition( "githubNotify context: 'ATH Results', " + "credentialsId: 'dummy', description: 'All tests are OK', sha: '0b5936eb903d439ac0c0bf84940d73128d5e9487'," + "repo: 'acceptance-test-harness', " + "status: 'SUCCESS', targetUrl: 'http://www.cloudbees.com'" )); WorkflowRun b1 = p.scheduleBuild2(0).waitForStart(); jenkins.assertBuildStatus(Result.FAILURE, jenkins.waitForCompletion(b1)); jenkins.assertLogContains(GitHubStatusNotificationStep.Execution.UNABLE_TO_INFER_DATA, b1); }
Example #24
Source File: ZulipNotifier.java From zulip-plugin with MIT License | 5 votes |
/** * Tests if the build should actually published<br/> * If SmartNotify is enabled, only notify if: * <ol> * <li>There was no previous build</li> * <li>The current build did not succeed</li> * <li>The previous build failed and the current build succeeded.</li> * </ol> * * @return true if build should be published */ private boolean shouldPublish(Run<?, ?> build) { if (SmartNotification.isSmartNotifyEnabled(smartNotification, DESCRIPTOR.isSmartNotify())) { Run<?, ?> previousBuild = build.getPreviousBuild(); if (previousBuild == null || getBuildResult(build) != Result.SUCCESS || getBuildResult(previousBuild) != Result.SUCCESS) { return true; } } else { return true; } return false; }
Example #25
Source File: DecisionMakerTest.java From office-365-connector-plugin with Apache License 2.0 | 5 votes |
@Test public void isStatusMatched_OnNotifyAndResultUnstable_ReturnsTrue() { // given DecisionMaker decisionMaker = buildSampleDecisionMaker(Result.UNSTABLE); Webhook webhook = new Webhook("someUrl"); webhook.setNotifyUnstable(true); // when boolean statusMatched = decisionMaker.isStatusMatched(webhook); // then assertThat(statusMatched).isTrue(); }
Example #26
Source File: QualityGateITest.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Tests if the build is considered a failure when thresholds for unstable and for failure are reached. */ @Test public void shouldOverrideUnstableWhenFailureAndUnstableThresholdIsReachedNew() { FreeStyleProject project = createFreeStyleProject(); enableAndConfigureCheckstyle(project, recorder -> { recorder.addQualityGate(1, QualityGateType.TOTAL, QualityGateResult.UNSTABLE); recorder.addQualityGate(3, QualityGateType.TOTAL_LOW, QualityGateResult.FAILURE); }); runJobTwice(project, Result.FAILURE); }
Example #27
Source File: PhabricatorNotifierTest.java From phabricator-jenkins-plugin with MIT License | 5 votes |
@Test public void testPostCoverageWithoutPublisher() throws Exception { TestUtils.addCopyBuildStep(p, "src/coverage/" + TestUtils.COBERTURA_XML, XmlCoverageProvider.class, "go-torch-coverage.xml"); FreeStyleBuild build = buildWithConduit(getFetchDiffResponse(), null, new JSONObject()); assertEquals(Result.SUCCESS, build.getResult()); assertLogContains("Publishing coverage data to Harbormaster for 3 files", build); }
Example #28
Source File: KubernetesPipelineTest.java From kubernetes-plugin with Apache License 2.0 | 5 votes |
@Issue("JENKINS-49707") @Test public void terminatedPod() throws Exception { r.waitForMessage("+ sleep", b); deletePods(cloud.connect(), getLabels(this, name), false); r.assertBuildStatus(Result.ABORTED, r.waitForCompletion(b)); r.waitForMessage(new ExecutorStepExecution.RemovedNodeCause().getShortDescription(), b); }
Example #29
Source File: SubBuildScheduler.java From DotCi with MIT License | 5 votes |
public CurrentBuildState waitForCompletion(final DynamicSubProject c, final TaskListener listener) throws InterruptedException { // wait for the completion int appearsCancelledCount = 0; while (true) { Thread.sleep(1000); final CurrentBuildState b = c.getCurrentStateByNumber(this.dynamicBuild.getNumber()); if (b != null) { // its building or is done if (b.isBuilding()) { continue; } else { final Result buildResult = b.getResult(); if (buildResult != null) { return b; } } } else { // not building or done, check queue final Queue.Item qi = c.getQueueItem(); if (qi == null) { appearsCancelledCount++; listener.getLogger().println(c.getName() + " appears cancelled: " + appearsCancelledCount); } else { appearsCancelledCount = 0; } if (appearsCancelledCount >= 5) { listener.getLogger().println(Messages.MatrixBuild_AppearsCancelled(ModelHyperlinkNote.encodeTo(c))); return new CurrentBuildState("COMPLETED", Result.ABORTED); } } } }
Example #30
Source File: GitLabVotePublisherTest.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
@Test public void removePreviousVote() throws IOException, InterruptedException { // GIVEN AbstractBuild build = mockSimpleBuild(GITLAB_CONNECTION_V4, Result.FAILURE); mockAward("v4", MERGE_REQUEST_IID, 1, "thumbsdown"); // WHEN performAndVerify(build, "v4", MERGE_REQUEST_IID, "thumbsdown"); // THEN mockServerClient.verify(prepareSendMessageWithSuccessResponse(build, "v4", MERGE_REQUEST_IID, "thumbsdown")); mockServerClient.verify(awardEmojiRequest("v4", MERGE_REQUEST_IID, "POST") .withQueryStringParameter("name", "thumbsdown")); }