Azure / powershell

GH Action to run Az PowerShell scripts for developers and administrators to develop, deploy, and manage Microsoft Azure applications.
MIT License
60 stars 40 forks source link

Step succeeds while error stream is written #33

Closed geekzter closed 3 years ago

geekzter commented 3 years ago

Hi,

On my workflow step, I have configured:

errorActionPreference: Stop
failOnStandardError: true

Still the step succeeds, as can be seen below:

Screen Shot 2021-04-02 at 17 45 05
github-actions[bot] commented 3 years ago

This issue is marked need-to-triage for generating issues report.

github-actions[bot] commented 3 years ago

This issue is idle because it has been open for 14 days with no activity.

BALAGA-GAYATRI commented 3 years ago

Hi @geekzter , Can you share your workflow here.

kanika1894 commented 3 years ago

@geekzter any updates?

geekzter commented 3 years ago

Hi @kanika1894,

The workflow I use is at https://github.com/geekzter/azure-minecraft-docker/blob/main/.github/workflows/ci-vanilla.yml (line 173):

    - name: Test connection to Minecraft Server (pwsh)
      if: ${{ github.event_name == 'pull_request' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
      uses: Azure/powershell@v1
      env:
        AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
      with:
        inlineScript: | 
          # Wait for Minecraft to boot up
          $connectionAttempts = 0
          do {
            Start-Sleep -Seconds 10
            Write-Host "Pinging ${env:TF_OUT_minecraft_server_fqdn} on port ${env:TF_OUT_minecraft_server_port}..."
            try {
              $connectionAttempts++
              $mineCraftConnection = New-Object System.Net.Sockets.TcpClient($env:TF_OUT_minecraft_server_fqdn, $env:TF_OUT_minecraft_server_port) -ErrorAction SilentlyContinue
            } catch [System.Management.Automation.MethodInvocationException] {
              Write-Warning $_
            }
          } while ((!$mineCraftConnection || !$mineCraftConnection.Connected) -and ($connectionAttempts -le 10))

          az container show --ids ${{ steps.terraform-apply.outputs.container_group_id }} --query instanceView
          az container logs --ids ${{ steps.terraform-apply.outputs.container_group_id }}
          # BUG: no tty
          # az container exec --ids ${{ steps.terraform-apply.outputs.container_group_id }} --exec-command "rcon-cli say hello from ci" --container-name minecraft
        azPSVersion: latest
        errorActionPreference: Stop
        failOnStandardError: true # BUG: setting not honored! `https://github.com/Azure/powershell/issues/33`

I've learned that this task is not really needed if you use azure/login@v1 and then the stock run task with shell pwsh.

github-actions[bot] commented 3 years ago

This issue is idle because it has been open for 14 days with no activity.

BALAGA-GAYATRI commented 3 years ago

hey @geekzter if you add a step for azure/login@v1 before you execute az-pwsh commands, you will not face the issue. Make sure you setenable-AzPSSession: true in azure/login Have a look at the detailed example . Let us know if it works.

geekzter commented 3 years ago

Hi @BALAGA-GAYATRI. Yes, that's what I already did and that works. That solved some other stability issue's as well. So I'm no longer impacted by the issue.

kanika1894 commented 3 years ago

That's good to know @geekzter 😇