Search code examples
azure-devopsbuild-pipeline

Azure build pipeline sporadic error, [CredentialProvider]Device flow authentication failed


This happened maybe once every 2 weeks, but lately it happens a few times until the build succeeds once.

GET https://api.nuget.org/v3-flatcontainer/xamarin.uitest/3.0.9/xamarin.uitest.3.0.9.nupkg ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets(128,5): Error : [CredentialProvider]Device flow authentication failed. User was presented with device flow, but didn't react within 90 seconds.

----- Update ---- After further digging in the logs, I found out that it was due to an 401 (Unauthorized) access to a private feed (in the same organization as the project where the pipeline fails). A temporary solution was to remove the specific *.csproj, that needed this private feed, from the solution build config, and also remove the private feed from the pipeline. This got the pipeline working again.

---- More Pipeline infos ---- I can't post the entire code here.

pool:
  vmImage: 'windows-latest'

variables:
  configuration: NugetB

steps:
- task: MSBuild
  displayName: 'MSBuild'
  inputs:
    solution: '**\xxSolutionxx.sln'
    msbuildArchitecture: 'x64'
    configuration: '$(configuration)'
    msbuildArguments: '/t:restore;build;pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:RestoreAdditionalProjectSources=https://urlToPrivateFeedInTheSameOrganization /p:configuration=$(configuration) /p:NuGetInteractive="true"'

Solution

  • Azure build pipeline sporadic error, [CredentialProvider]Device flow authentication failed

    If you have task/script access to azure ariftact feed in your pipeline, then please try to use the System.AccessToken variable to authenticate a pipeline to a private Azure Artifacts feed or try to reset your PAT.

    You could check this document for some more details.

    Besides, if above not resolve your question, please share how did you access the artifact and the build pipeline configuration.