Skip to content

Poi #56

Description

@Megs1gteg

Ok found the problem. If you have never run a security check on the main branch, the script will fail at this line because you will get a branchnotfoundexception.


while ($retries -gt 0) {

    try {

        $alertsPRTarget = Invoke-WebRequest -Uri $urlTargetAlerts -Headers $headers -Method Get -ErrorAction Stop

        # Success

        break

    }

Perhaps the catch block can be changed to skip the error? Is it possible that the target branch may not exist when the script is run from a pull request?


catch {

        # No GHAzDO results on the target branch, wait and retry?

        if ($_.ErrorDetails.Message.Split("`"") -contains "BranchNotFoundException") {

            $retries--

            if ($retries -eq 0) {

                # We have retried the maximum number of times, give up

                Write-Host "##vso[task.logissue type=error] We have retried the maximum number of times, give up."

                throw $_

            }



            # Wait and then try again

            Write-Host "There are no GHAzDO results on the target branch, wait and try again."

            Start-Sleep -Seconds 60

        }

Originally posted by Christoph Piock-Ellena (@cpiock) in #50

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions