diff --git a/app/com/ysoft/odc/BambooDownloader.scala b/app/com/ysoft/odc/BambooDownloader.scala index 5618685..8ef1942 100644 --- a/app/com/ysoft/odc/BambooDownloader.scala +++ b/app/com/ysoft/odc/BambooDownloader.scala @@ -3,7 +3,7 @@ package com.ysoft.odc import com.google.inject.Inject import com.google.inject.name.Named import org.ccil.cowan.tagsoup.jaxp.SAXFactoryImpl -import play.api.libs.ws.{WS, WSAuthScheme, WSClient, WSRequest} +import play.api.libs.ws.{WS, WSClient} import upickle.default._ import scala.concurrent.{ExecutionContext, Future} @@ -128,8 +128,16 @@ final class BambooDownloader @Inject()(@Named("bamboo-server-url") val server: S val resultsFuture = Future.traverse(projects){project => downloadProjectReport(project, requiredVersions.get(project)) } - resultsFuture.map{ results => - val (successfulReportTries, failedReportTries) = results.partition(_._2.isSuccess) + resultsFuture.map{ originalResults => + val buildFailureFilteredResults = originalResults.map{case (name, resultTry) => + name -> resultTry.flatMap{ case result @ (build, _, _) => + // Note that this is triggered only if the artifact directory exists. + // If it does not, it will throw “java.util.NoSuchElementException: key not found: Report results-XML” instead. + if (build.state != "Successful" || build.buildState != "Successful") Failure(new RuntimeException("failed build")) + else Success(result) + } + } + val (successfulReportTries, failedReportTries) = buildFailureFilteredResults.partition(_._2.isSuccess) val successfulReports = successfulReportTries.map{case (name, Success(data)) => name -> data; case _ => ???}.toMap val failedReports = failedReportTries.map{case (name, Failure(data)) => name -> data; case _ => ???}.toMap (successfulReports, failedReports) diff --git a/app/controllers/DependencyCheckReportsProcessor.scala b/app/controllers/DependencyCheckReportsProcessor.scala index 838ce2d..bff2614 100644 --- a/app/controllers/DependencyCheckReportsProcessor.scala +++ b/app/controllers/DependencyCheckReportsProcessor.scala @@ -73,9 +73,7 @@ final class DependencyCheckReportsProcessor @Inject() ( ) val unknownIdentifierTypes = allDependencies.flatMap(_._1.identifiers.map(_.identifierType)).toSet -- Set("maven", "cpe") - val failedReports = successfulResults.filter(x => x._2._1.state != "Successful" || x._2._1.buildState != "Successful") val extraWarnings = Seq[Option[Warning]]( - if(failedReports.size > 0) Some(IdentifiedWarning("failed-reports", views.html.warnings.failedReports(failedReports.values.map{case (b, _ ,_) => b}.toSet, server), WarningSeverity.Error)) else None, if(unknownIdentifierTypes.size > 0) Some(IdentifiedWarning("unknown-identifier-types", views.html.warnings.unknownIdentifierType(unknownIdentifierTypes), WarningSeverity.Info)) else None, { val emptyResults = successfulResults.filter{case (k, (_, dir, _)) => dir.flatFiles.size < 1}