Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication failure when using in GitHub Action on Linux agent #21

Open
flcdrg opened this issue Sep 16, 2021 · 3 comments
Open

Authentication failure when using in GitHub Action on Linux agent #21

flcdrg opened this issue Sep 16, 2021 · 3 comments

Comments

@flcdrg
Copy link

flcdrg commented Sep 16, 2021

I'm using this module as a step in a GitHub Action workflow.

      - name: Queue build
        env:
          AZURE_DEVOPS_TOKEN: ${{ secrets.AZURE_DEVOPS_TOKEN }}
        shell: pwsh
        run: |
          Install-Module AzurePipelinesPS -Repository PSGallery -Force
          Import-Module AzurePipelinesPS

          $secureToken = ConvertTo-SecureString -String $env:AZURE_DEVOPS_TOKEN -AsPlainText

          Get-APBuildDefinition -Project MyProject -Collection MyCollection -PersonalAccessToken $secureToken -Instance 'https://dev.azure.com/' -ApiVersion '6.0' -DefinitionID 1 -Verbose

If the job that this step runs in has runs-on: ubuntu-latest, then the Get-APBuildDefinition fails (returns the standard html text saying you need to log in).

If I set runs-on: windows-latest then the call succeeds.

Not sure why a Linux runner would cause it to fail

@Dejulia489
Copy link
Owner

I don't believe ${{ secrets.AZURE_DEVOPS_TOKEN }} resolves to anything. You may be looking for ${{ parameters.AZURE_DEVOPS_TOKEN }}

@flcdrg
Copy link
Author

flcdrg commented Apr 15, 2022

${{ secrets.AZURE_DEVOPS_TOKEN }} resolves to the secret I have set in my GitHub repository named AZURE_DEVOPS_TOKEN.

The fact that the only change I made was the runs-on line implies that the environment variable is being set correctly.

@Dejulia489
Copy link
Owner

I would assume this has to do with how the env variables are resolved on a Linux runner vs a windows runner. Can you take the Git Hub action out of the loop and try to run the command directly on your Linux machine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants