AzurePipelinesPS
AzurePipelinesPS copied to clipboard
Authentication failure when using in GitHub Action on Linux agent
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
I don't believe ${{ secrets.AZURE_DEVOPS_TOKEN }}
resolves to anything. You may be looking for ${{ parameters.AZURE_DEVOPS_TOKEN }}
${{ 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.
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?