hudson.model.Run Java Examples

The following examples show how to use hudson.model.Run. 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: GetAttachmentInfoStepTest.java    From jira-steps-plugin with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getAttachment(anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
 
Example #2
Source File: DeflakeListener.java    From flaky-test-handler-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void onCompleted(Run run, TaskListener listener) {
  // TODO consider the possibility that there is >1 such action
  TestResultAction testResultAction = run.getAction(TestResultAction.class);

  HistoryAggregatedFlakyTestResultAction historyAction = run.getParent()
      .getAction(HistoryAggregatedFlakyTestResultAction.class);

  // Aggregate test running results
  if (historyAction != null) {
    historyAction.aggregateOneBuild(run);
  }

  if (testResultAction != null && testResultAction.getFailCount() > 0) {
    // Only add deflake action if there are test failures
    run.addAction(
        new DeflakeAction(getFailingTestClassMethodMap(testResultAction.getFailedTests())));
  }
}
 
Example #3
Source File: DockerBuilderControlOptionRun.java    From docker-plugin with MIT License 6 votes vote down vote up
private void executePullOnDocker(Run<?, ?> build, PrintStream llog, String xImage, DockerClient client)
        throws DockerException {
    PullImageResultCallback resultCallback = new PullImageResultCallback() {
        @Override
        public void onNext(PullResponseItem item) {
            if (item.getStatus() != null && item.getProgress() == null) {
                llog.print(item.getId() + ":" + item.getStatus());
                LOG.info("{} : {}", item.getId(), item.getStatus());
            }
            super.onNext(item);
        }
    };

    PullImageCmd cmd = client.pullImageCmd(xImage);
    DockerCloud.setRegistryAuthentication(cmd, getRegistry(), build.getParent().getParent());
    try {
        cmd.exec(resultCallback).awaitCompletion();
    } catch (InterruptedException e) {
        throw new DockerClientException("Interrupted while pulling image", e);
    }
}
 
Example #4
Source File: PipelineHelper.java    From jenkins-build-monitor-plugin with MIT License 6 votes vote down vote up
public static boolean isWorkflowRun(Run<?, ?> build, StaticJenkinsAPIs staticJenkinsAPIs) {
    //Cache class lookup
    if (hasWorkflowClass == null) {
        if (!staticJenkinsAPIs.hasPlugin(PIPELINE_PLUGIN)) {
            hasWorkflowClass = false;
            return false;
        }
        try {
            workflowRunClass = Class.forName(WORKFLOW_RUN_CLASS_NAME);
            hasWorkflowClass = true;
        } catch (ClassNotFoundException e) {
            hasWorkflowClass = false;
            return false;
        }
    }
    if (hasWorkflowClass) {
        return workflowRunClass.isInstance(build);
    }
    return false;
}
 
Example #5
Source File: EditVersionStepTest.java    From jira-steps-plugin with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Void> builder = ResponseData.builder();
  when(jiraServiceMock.updateVersion(anyString(), any()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);

}
 
Example #6
Source File: DockerBuildImageStep.java    From yet-another-docker-plugin with MIT License 6 votes vote down vote up
@Override
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher,
                    @Nonnull TaskListener listener) throws InterruptedException, IOException {
    PrintStream llog = listener.getLogger();
    try {
        llog.println("Executing remote build image...");
        List<String> buildImages = workspace.act(newDockerBuildImageStepCallable()
                .withBuildImage(buildImage)
                .withConnector(connector)
                .withTaskListener(listener)
        );
        llog.println(buildImages);
    } catch (Throwable ex) {
        LOG.error("Can't build image", ex);
        throw ex;
    }
}
 
Example #7
Source File: GithubBuildStatusGraphListener.java    From github-autostatus-plugin with MIT License 6 votes vote down vote up
/**
 * Gets a list of stages in a declarative pipeline.
 *
 * @param run a particular run of a job
 * @return a list of stage names
 */
protected static List<BuildStage> getDeclarativeStages(Run<?, ?> run) {
    ExecutionModelAction executionModelAction = run.getAction(ExecutionModelAction.class);
    if (null == executionModelAction) {
        return null;
    }
    ModelASTStages stages = executionModelAction.getStages();
    if (null == stages) {
        return null;
    }
    List<ModelASTStage> stageList = stages.getStages();
    if (null == stageList) {
        return null;
    }
    return convertList(stageList);
}
 
Example #8
Source File: ReportScanningTool.java    From warnings-ng-plugin with MIT License 6 votes vote down vote up
@Override
public Report scan(final Run<?, ?> run, final FilePath workspace, final Charset sourceCodeEncoding,
        final LogHandler logger) {
    String actualPattern = getActualPattern();
    if (StringUtils.isBlank(actualPattern)) {
        return scanInConsoleLog(workspace, run, logger);
    }
    else {
        if (StringUtils.isBlank(getPattern())) {
            logger.log("Using default pattern '%s' since user defined pattern is not set",
                    getDescriptor().getPattern());
        }

        return scanInWorkspace(workspace, expandPattern(run, actualPattern), logger);
    }
}
 
Example #9
Source File: PipelineGraphPublisher.java    From pipeline-maven-plugin with MIT License 6 votes vote down vote up
@Override
public void process(@Nonnull StepContext context, @Nonnull Element mavenSpyLogsElt) throws IOException, InterruptedException {
    Run run = context.get(Run.class);
    TaskListener listener = context.get(TaskListener.class);

    PipelineMavenPluginDao dao = GlobalPipelineMavenConfig.get().getDao();

    List<MavenArtifact> parentProjects = listParentProjects(mavenSpyLogsElt, LOGGER);
    List<MavenDependency> dependencies = listDependencies(mavenSpyLogsElt, LOGGER);
    List<MavenArtifact> generatedArtifacts = XmlUtils.listGeneratedArtifacts(mavenSpyLogsElt, true);
    List<String> executedLifecyclePhases = XmlUtils.getExecutedLifecyclePhases(mavenSpyLogsElt);
    
    recordParentProject(parentProjects, run,listener, dao);
    recordDependencies(dependencies, generatedArtifacts, run, listener, dao);
    recordGeneratedArtifacts(generatedArtifacts, executedLifecyclePhases, run, listener, dao);
}
 
Example #10
Source File: InfluxDbNotifier.java    From github-autostatus-plugin with MIT License 6 votes vote down vote up
private String notifyTestCase(String jobName, String suiteName, TestCase testCase, Run<?, ?> run) {
       String buildUrl = run.getUrl();
       int buildNumber = run.getNumber();
       Cause cause = run.getCause(Cause.class);
       String buildCause = cause == null ? BuildNotifierConstants.DEFAULT_STRING : cause.getShortDescription();

       String data = config.getSchema().formatTestCase(jobName,
               repoOwner,
               repoName,
               branchName,
               suiteName,
               testCase.getName(),
               testCase.getPassedCount(),
               testCase.getSkippedCount(),
               testCase.getFailedCount(),
               buildUrl,
               buildNumber,
               buildCause);

return data;
   }
 
Example #11
Source File: JobHelper.java    From github-integration-plugin with MIT License 6 votes vote down vote up
public static void addComment(final int id, final String comment, final Run<?, ?> run, final TaskListener listener) {
    if (comment == null || comment.trim().isEmpty()) {
        return;
    }

    String finalComment = comment;
    if (nonNull(run) && nonNull(listener)) {
        try {
            finalComment = run.getEnvironment(listener).expand(comment);
        } catch (Exception e) {
            LOG.error("Error", e);
        }
    }

    try {
        if (nonNull(run)) {
            final GitHubPRTrigger trigger = ghPRTriggerFromRun(run);

            GHRepository ghRepository = trigger.getRemoteRepository();
            ghRepository.getPullRequest(id).comment(finalComment);
        }
    } catch (IOException ex) {
        LOG.error("Couldn't add comment to pull request #{}: '{}'", id, finalComment, ex);
    }
}
 
Example #12
Source File: TestResultProjectAction.java    From junit-plugin with MIT License 6 votes vote down vote up
public AbstractTestResultAction getLastTestResultAction() {
    final Run<?,?> tb = job.getLastSuccessfulBuild();

    Run<?,?> b = job.getLastBuild();
    while(b!=null) {
        AbstractTestResultAction a = b.getAction(AbstractTestResultAction.class);
        if(a!=null && (!b.isBuilding())) return a;
        if(b==tb)
            // if even the last successful build didn't produce the test result,
            // that means we just don't have any tests configured.
            return null;
        b = b.getPreviousBuild();
    }

    return null;
}
 
Example #13
Source File: TelegramBot.java    From telegram-notifications-plugin with MIT License 6 votes vote down vote up
public void sendMessage(
        Long chatId, String message, Run<?, ?> run, FilePath filePath, TaskListener taskListener)
        throws IOException, InterruptedException {

    final String expandedMessage = expandMessage(message, run, filePath, taskListener);

    try {
        if (chatId == null) {
            SUBSCRIBERS.getApprovedUsers()
                    .forEach(user -> this.sendMessage(user.getId(), expandedMessage));
        } else {
            sendMessage(chatId, expandedMessage);
        }

    } catch (Exception e) {
        LOG.log(Level.SEVERE, "Error while sending the message", e);
    }

    if (CONFIG.isShouldLogToConsole()) taskListener.getLogger().println(expandedMessage);
}
 
Example #14
Source File: ReferenceFinderITest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
/**
 * Checks if the reference only looks at the eclipse result of a build and not the overall success. Should return an
 * unstable result. Uses a different freestyle project for the reference.
 */
@Test
public void shouldCreateUnstableResultWithOverAllMustNotBeSuccessWithReferenceBuild() {
    // #1 SUCCESS
    FreeStyleProject reference = createJob(REFERENCE_JOB_NAME, "eclipse4Warnings.txt");
    IssuesRecorder issuesRecorder = enableWarnings(reference, recorder -> {
        recorder.setIgnoreFailedBuilds(false);
        recorder.setEnabledForFailure(true);
    });
    scheduleBuildAndAssertStatus(reference, Result.SUCCESS,
            analysisResult -> assertThat(analysisResult).hasTotalSize(4)
                    .hasNewSize(0)
                    .hasQualityGateStatus(QualityGateStatus.INACTIVE));

    // #2 FAILURE
    cleanAndCopy(reference, "eclipse2Warnings.txt");
    issuesRecorder.addQualityGate(3, QualityGateType.NEW, QualityGateResult.UNSTABLE);
    Builder failureStep = addFailureStep(reference);
    Run<?, ?> expectedReference = scheduleBuildAndAssertStatus(reference, Result.FAILURE,
            analysisResult -> assertThat(analysisResult).hasTotalSize(2)
                    .hasNewSize(0)
                    .hasQualityGateStatus(QualityGateStatus.PASSED)).getOwner();
    removeBuilder(reference, failureStep);

    // #1 UNSTABLE (Reference #2)
    FreeStyleProject project = createJob(JOB_NAME, "eclipse6Warnings.txt");
    enableWarnings(project, recorder -> {
        recorder.addQualityGate(3, QualityGateType.NEW, QualityGateResult.UNSTABLE);
        recorder.setReferenceJobName(REFERENCE_JOB_NAME);
        recorder.setIgnoreFailedBuilds(false);
        recorder.setEnabledForFailure(true);
    });
    scheduleBuildAndAssertStatus(project, Result.UNSTABLE,
            analysisResult -> assertThat(analysisResult).hasTotalSize(6)
                    .hasNewSize(4)
                    .hasQualityGateStatus(QualityGateStatus.WARNING)
                    .hasReferenceBuild(Optional.of(expectedReference)));
}
 
Example #15
Source File: HubotAbstractSynchronousNonBlockingStepExecution.java    From hubot-steps-plugin with Apache License 2.0 5 votes vote down vote up
protected HubotAbstractSynchronousNonBlockingStepExecution(StepContext context)
    throws IOException, InterruptedException {
  super(context);
  run = context.get(Run.class);
  listener = context.get(TaskListener.class);
  envVars = context.get(EnvVars.class);
}
 
Example #16
Source File: UsernamePasswordMultiBinding.java    From credentials-binding-plugin with MIT License 5 votes vote down vote up
@Override public MultiEnvironment bind(@Nonnull Run<?, ?> build,
                                       @Nullable FilePath workspace,
                                       @Nullable Launcher launcher,
                                       @Nonnull TaskListener listener) throws IOException, InterruptedException {
    StandardUsernamePasswordCredentials credentials = getCredentials(build);
    Map<String,String> m = new LinkedHashMap<>();
    m.put(usernameVariable, credentials.getUsername());
    m.put(passwordVariable, credentials.getPassword().getPlainText());
    return new MultiEnvironment(m);
}
 
Example #17
Source File: BlueTestResultFactory.java    From blueocean-plugin with MIT License 5 votes vote down vote up
public static Result resolve(Run<?,?> run, Reachable parent) {
    Iterable<BlueTestResult> results = ImmutableList.of();
    BlueTestSummary summary = new BlueTestSummary(0, 0, 0, 0, 0, 0, 0, //
                                                  parent == null ? null : parent.getLink());
    for (BlueTestResultFactory factory : allFactories()) {
        Result result = factory.getBlueTestResults(run, parent);
        if (result != null && result.results != null && result.summary != null) {
            results = Iterables.concat(result.results, results);
            summary = summary.tally(result.summary);
        }
    }
    return getResult(results, summary);
}
 
Example #18
Source File: BaseTest.java    From blueocean-plugin with MIT License 5 votes vote down vote up
protected void validatePipeline(Job p, Map resp){
    Assert.assertEquals("jenkins", resp.get("organization"));
    Assert.assertEquals(p.getName(), resp.get("name"));
    Assert.assertEquals(p.getDisplayName(), resp.get("displayName"));
    Assert.assertEquals(p.getFullName(), resp.get("fullName"));
    Assert.assertEquals(p.getBuildHealth().getScore(), resp.get("weatherScore"));

    if(p.getLastBuild() != null){
        Run r = p.getLastBuild();
        validateRun(r, (Map) resp.get("latestRun"), "FINISHED");
    }else{
        Assert.assertNull(resp.get("latestRun"));
    }
}
 
Example #19
Source File: ArtifactImplTest.java    From blueocean-plugin with MIT License 5 votes vote down vote up
@Test
public void findUniqueArtifactsWithSameName() throws IllegalAccessException {
    //mock artifacts
    Run.Artifact artifact1 = mock(Run.Artifact.class);
    Run.Artifact artifact2 = mock(Run.Artifact.class);
    //artifact1 mocks
    when(artifact1.getFileName()).thenReturn("test-suite.log");
    MemberModifier.field(Run.Artifact.class, "relativePath").set(artifact1, "path1/test-suite.log");
    when(artifact1.getHref()).thenReturn("path1/test-suite.log");
    //artifact2 mocks
    when(artifact2.getFileName()).thenReturn("test-suite.log");
    MemberModifier.field(Run.Artifact.class, "relativePath").set(artifact2, "path2/test-suite.log");
    when(artifact2.getHref()).thenReturn("path2/test-suite.log");
    //list of artifacts
    ArrayList artifactList = new ArrayList();
    artifactList.add(artifact1);
    artifactList.add(artifact2);
    //mock run
    Run run = mock(Run.class);
    when(run.getUrl()).thenReturn("job/myfolder/job/myjob/1/");
    when(run.getArtifacts()).thenReturn(artifactList);

    Link parentLink = mock(Link.class);

    ArtifactImpl a1 = new ArtifactImpl(run, artifact1, parentLink);
    ArtifactImpl a2 = new ArtifactImpl(run, artifact2, parentLink);
    assertThat(a1.getId(), is(not(a2.getId())));
}
 
Example #20
Source File: SimpleCaseResult.java    From junit-plugin with MIT License 5 votes vote down vote up
@Override
public Run<?,?> getRun() {
    if (parentAction == null) {
        LOGGER.warning("in Trivial Test Result, parentAction is null, but getRun() called");
        return null; 
    }
    return parentAction.run;
}
 
Example #21
Source File: DecisionMakerTest.java    From office-365-connector-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void DecisionMaker_OnEmptyPreviousBuild_StoresParameters() {

    // given
    Run run = mock(Run.class);
    TaskListener taskListener = mockListener();

    // when
    DecisionMaker decisionMaker = new DecisionMaker(run, taskListener);

    // then
    assertThat((Run) Deencapsulation.getField(decisionMaker, "run")).isSameAs(run);
    assertThat((TaskListener) Deencapsulation.getField(decisionMaker, "taskListener")).isSameAs(taskListener);
    assertThat((Result) Deencapsulation.getField(decisionMaker, "previousResult")).isEqualTo(Result.SUCCESS);
}
 
Example #22
Source File: MavenDependencyUpstreamCause.java    From pipeline-maven-plugin with MIT License 5 votes vote down vote up
/**
 * TODO create a PR on jenkins-core to make {@link hudson.model.Cause.UpstreamCause#print(TaskListener, int)} protected instead of private
 * <p>
 * Mimic {@link hudson.model.Cause.UpstreamCause#print(TaskListener, int)} waiting for this method to become protected instead of private
 *
 * @see UpstreamCause#print(TaskListener, int)
 */
private void print(TaskListener listener, int depth) {
    indent(listener, depth);
    Run<?, ?> upstreamRun = getUpstreamRun();

    if (upstreamRun == null) {
        listener.getLogger().println("Started by upstream build " + ModelHyperlinkNote.encodeTo('/' + getUpstreamUrl(), getUpstreamProject()) +
                "\" #" + ModelHyperlinkNote.encodeTo('/' + getUpstreamUrl() + getUpstreamBuild(), Integer.toString(getUpstreamBuild())) +
                " generating Maven artifact: " + getMavenArtifactsDescription());
    } else {
        listener.getLogger().println("Started by upstream build " +
                ModelHyperlinkNote.encodeTo('/' + upstreamRun.getUrl(), upstreamRun.getFullDisplayName()) + " generating Maven artifacts: " + getMavenArtifactsDescription());
    }

    if (getUpstreamCauses() != null && !getUpstreamCauses().isEmpty()) {
        indent(listener, depth);
        listener.getLogger().println("originally caused by:");
        for (Cause cause : getUpstreamCauses()) {
            if (cause instanceof MavenDependencyUpstreamCause) {
                ((MavenDependencyUpstreamCause) cause).print(listener, depth + 1);
            } else {
                indent(listener, depth + 1);
                cause.print(listener);
            }
        }
    }
}
 
Example #23
Source File: GitHubBranchRepository.java    From github-integration-plugin with MIT License 5 votes vote down vote up
@Override
@RequirePOST
public FormValidation doRebuild(StaplerRequest req) throws IOException {
    FormValidation result;

    try {
        if (!job.hasPermission(Item.BUILD)) {
            return FormValidation.error("Forbidden");
        }

        final String param = "branchName";
        String branchName = "";
        if (req.hasParameter(param)) {
            branchName = req.getParameter(param);
        }

        Map<String, List<Run<?, ?>>> allBuilds = getAllBranchBuilds();
        List<Run<?, ?>> branchBuilds = allBuilds.get(branchName);
        if (branchBuilds != null && !allBuilds.isEmpty()) {
            if (rebuild(branchBuilds.get(0))) {
                result = FormValidation.ok("Rebuild scheduled");
            } else {
                result = FormValidation.warning("Rebuild not scheduled");
            }
        } else {
            result = FormValidation.warning("Build not found");
        }
    } catch (Exception e) {
        LOG.error("Can't start rebuild", e.getMessage());
        result = FormValidation.error(e, "Can't start rebuild: " + e.getMessage());
    }
    return result;
}
 
Example #24
Source File: DeflakeListener.java    From flaky-test-handler-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void onStarted(Run build, TaskListener listener) {
  List<Cause> causesList = build.getCauses();
  try {
    for (Cause cause : causesList) {
      if (cause instanceof DeflakeCause) {
        build.setDisplayName(build.getDisplayName() + ": " + cause.getShortDescription());
        return;
      }
    }
  } catch (IOException e) {
    LOGGER.log(Level.SEVERE, "Failed to set deflake build name: " + e.getMessage());
  }
}
 
Example #25
Source File: DecisionMaker.java    From office-365-connector-plugin with Apache License 2.0 5 votes vote down vote up
public DecisionMaker(Run run, TaskListener listener) {
    this.run = run;
    this.taskListener = listener;

    Run previousBuild = run.getPreviousBuild();
    previousResult = previousBuild != null ? previousBuild.getResult() : Result.SUCCESS;
}
 
Example #26
Source File: GitLabConnectionProperty.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
public static GitLabClient getClient(@NotNull Run<?, ?> build) {
    Job<?, ?> job = build.getParent();
    if(job != null) {
        final GitLabConnectionProperty connectionProperty = job.getProperty(GitLabConnectionProperty.class);
        if (connectionProperty != null) {
            return connectionProperty.getClient();
        }
    }
    
    return null;
}
 
Example #27
Source File: AnalysisHistory.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
@Override
public BuildResult<AnalysisBuildResult> next() {
    if (cursor.isPresent()) {
        Run<?, ?> run = cursor.get();
        Optional<ResultAction> resultAction = selector.get(run);

        cursor = getRunWithResult(run.getPreviousBuild(), selector, IGNORE_QUALITY_GATE, IGNORE_JOB_RESULT);

        if (resultAction.isPresent()) {
            return new BuildResult<>(new JenkinsBuild(run), resultAction.get().getResult());
        }
    }

    throw new NoSuchElementException("No more runs with an analysis result available: " + cursor);
}
 
Example #28
Source File: PipelineEventListener.java    From blueocean-plugin with MIT License 5 votes vote down vote up
private static void publishJobEvent(@Nonnull Run<?,?> run, @Nonnull Events.JobChannel event) {
    try {
        // TODO: What's the actual event we should send here?
        PubsubBus.getBus().publish(new RunMessage(run)
            .setEventName(event)
        );
    } catch (MessageException e) {
        LOGGER.log(Level.WARNING, "Error publishing Job event.", e);
    }
}
 
Example #29
Source File: AnalysisResult.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
/**
 * Creates a new instance of {@link AnalysisResult}.
 *
 * @param owner
 *         the current build as owner of this action
 * @param id
 *         ID of the results
 * @param report
 *         the issues of this result
 * @param blames
 *         author and commit information for all issues
 * @param totals
 *         repository statistics for all issues
 * @param qualityGateStatus
 *         the quality gate status
 * @param sizePerOrigin
 *         the number of issues per origin
 * @param previousResult
 *         the analysis result of the previous run
 */
@SuppressWarnings("checkstyle:ParameterNumber")
public AnalysisResult(final Run<?, ?> owner, final String id, final DeltaReport report, final Blames blames,
        final RepositoryStatistics totals, final QualityGateStatus qualityGateStatus,
        final Map<String, Integer> sizePerOrigin,
        final AnalysisResult previousResult) {
    this(owner, id, report, blames, totals, qualityGateStatus, sizePerOrigin, true);

    if (report.isEmpty()) {
        if (previousResult.noIssuesSinceBuild == NO_BUILD) {
            noIssuesSinceBuild = owner.getNumber();
        }
        else {
            noIssuesSinceBuild = previousResult.noIssuesSinceBuild;
        }
    }
    else {
        noIssuesSinceBuild = NO_BUILD;
    }

    if (this.qualityGateStatus == QualityGateStatus.PASSED) {
        if (previousResult.qualityGateStatus == QualityGateStatus.PASSED) {
            successfulSinceBuild = previousResult.successfulSinceBuild;
        }
        else {
            successfulSinceBuild = owner.getNumber();
        }
    }
    else {
        successfulSinceBuild = NO_BUILD;
    }
}
 
Example #30
Source File: BuildFlowAction.java    From yet-another-build-visualizer-plugin with MIT License 5 votes vote down vote up
public static boolean hasUpstreamOrDownstreamBuilds(Run target) {
  if (target == null) {
    return false;
  }
  return BuildCache.getCache().getDownstreamBuilds(target).size() > 0
      || BuildCache.getDownstreamQueueItems(target).size() > 0
      || getUpstreamBuild(target) != null;
}