Пример #1
0
        public void WaitForScanComplete(HttpClient client, HubPagedResponse <ScanSummaryView> currentPagedSummaries)
        {
            int currentSummaries = 0;

            if (currentPagedSummaries != null)
            {
                currentSummaries = currentPagedSummaries.TotalCount;
            }

            Stopwatch        stopwatch    = Stopwatch.StartNew();
            CodeLocationView codeLocation = null;

            while (stopwatch.ElapsedMilliseconds / 1000 < HubScanTimeout)
            {
                Log.LogMessage("Checking scan summary status");
                codeLocation = CodeLocationDataService.GetCodeLocationView(BdioId);
                if (codeLocation != null)
                {
                    break;
                }
                else
                {
                    Log.LogMessage("No code locations found. Trying again...");
                    Thread.Sleep(500);
                }
            }

            if (codeLocation == null)
            {
                throw new BlackDuckIntegrationException($"Failed to get the codelocation for {HubProjectName} ");
            }

            ScanStatusEnum currentStatus = ScanStatusEnum.UNSTARTED;

            while (stopwatch.ElapsedMilliseconds / 1000 < HubScanTimeout)
            {
                HubPagedResponse <ScanSummaryView> scanSummaries = ScanSummariesDataService.GetScanSummaries(codeLocation);
                if (scanSummaries == null || scanSummaries.Items == null)
                {
                    throw new BlackDuckIntegrationException($"There are no scan summaries @: {codeLocation.Metadata.Href}");
                }
                else if (scanSummaries.TotalCount > currentSummaries)
                {
                    ScanSummaryView scanSummary = scanSummaries.Items[0];
                    ScanStatusEnum  scanStatus  = scanSummary.Status;
                    if (!scanStatus.Equals(currentStatus))
                    {
                        currentStatus = scanStatus;
                        Log.LogMessage($"\tScan Status = {currentStatus} @ {stopwatch.ElapsedMilliseconds / 1000.0}");
                    }
                    if (currentStatus.Equals(ScanStatusEnum.COMPLETE))
                    {
                        stopwatch.Stop();
                        break;
                    }
                }
                Thread.Sleep(500);
            }

            if (stopwatch.ElapsedMilliseconds / 1000 > HubScanTimeout)
            {
                throw new BlackDuckIntegrationException($"Scanning of the codelocation: {codeLocation.Metadata.Href} execeded the {HubScanTimeout} second timeout");
            }
        }
Пример #2
0
 public bool IsDone(ScanStatusEnum statusEnum)
 {
     return(DONE_STATES.Contains(statusEnum));
 }
Пример #3
0
 public bool IsError(ScanStatusEnum statusEnum)
 {
     return(ERROR_STATES.Contains(statusEnum));
 }
Пример #4
0
 public bool IsPending(ScanStatusEnum statusEnum)
 {
     return(PENDING_STATES.Contains(statusEnum));
 }