我创建了一个应该发布工件的天蓝色管道。
trigger:
tags:
include:
- '*'
variables:
- name: PackageName
value: 'Netizen.Configuration'
- name: Version
value: # Determined by tag on repo
steps:
- checkout: self
# Extract tag name and set it as Version
- powershell: |
$tag = "$(Build.SourceBranch)".Replace("refs/tags/", "")
Write-Host "##vso[task.setvariable variable=Version]$tag"
displayName: 'Get tag version'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
- powershell: |
Write-Host "Version is '$(Version)'"
displayName: 'Print Version'
- task: gitversion/setup@0
displayName: 'Installing GitVersion'
inputs:
versionSpec: '5.x'
- task: gitversion/execute@0
displayName: 'Running GitVersion'
inputs:
additionalArguments: '/updateprojectfiles'
- task: NuGetAuthenticate@1
displayName: 'Authenticating NuGet'
- task: DotNetCoreCLI@2
displayName: 'Restoring packages'
inputs:
command: 'restore'
projects: '**/*.sln'
feedsToUse: 'select'
vstsFeed: '8c97****-****-****-****-********4bdd/1366****-****-****-****-********6d5d'
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '**/*.sln'
arguments: '--no-restore'
- task: DotNetCoreCLI@2
displayName: 'Run tests'
inputs:
command: 'test'
projects: '**/*Tests.csproj'
testRunTitle: 'Running tests'
nobuild: true
# Conditional Pack Step when Version is set
- task: DotNetCoreCLI@2
condition: and(succeeded(), ne(variables['Version'], ''), ne(variables['Version'], 'undefined'))
displayName: 'Creating package'
inputs:
command: 'pack'
packagesToPack: '**/$(PackageName).csproj'
includesymbols: true
versioningScheme: 'off'
buildProperties: 'Version=$(Version)'
# Conditional Publish Step when Version is set
- task: NuGetCommand@2
condition: and(succeeded(), ne(variables['Version'], ''), ne(variables['Version'], 'undefined'))
displayName: 'Publishing package'
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: '8c97****-****-****-****-********4bdd/1366****-****-****-****-********6d5d'
这一切都适用于最后一个“发布包”步骤
NuGetCommand@2
。
这是错误输出。
[CredentialProvider]VstsBuildTaskCredentialProvider - Matched prefix: https://mrpmorris.pkgs.visualstudio.com/
[CredentialProvider]VstsBuildTaskCredentialProvider - Found credentials for endpoint https://mrpmorris.pkgs.visualstudio.com/GUID1/_packaging/GUID2/nuget/v3/index.json
[CredentialProvider]Sending response: 'Request' 'GetAuthenticationCredentials'. Time elapsed in ms: 23
[CredentialProvider]Time elapsed in milliseconds after sending response 'Request' 'GetAuthenticationCredentials': 28
Pushing Netizen.Configuration.0.0.2.nupkg to 'https://mrpmorris.pkgs.visualstudio.com/GUID1/_packaging/GUID2/nuget/v2/'...
PUT https://mrpmorris.pkgs.visualstudio.com/GUID1/_packaging/GUID2/nuget/v2/
Forbidden https://mrpmorris.pkgs.visualstudio.com/GUID1/_packaging/GUID2/nuget/v2/ 38ms
System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 (Forbidden - User 'GUID3' lacks permission to complete this action. You need to have 'AddPackage'. (DevOps Activity ID: GUID4)).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode () [0x00040] in <dec5519efdf9482fbfb76832fbc71b94>:0
at NuGet.Protocol.Core.Types.PackageUpdateResource+<>c.<PushPackageToServer>b__23_0 (System.Net.Http.HttpResponseMessage response) [0x00000] in <dc1b484fc03b4c9e94db6d2032a7a13d>:0
at NuGet.Protocol.HttpSource.ProcessResponseAsync[T] (NuGet.Protocol.HttpSourceRequest request, System.Func`2[T,TResult] processAsync, NuGet.Protocol.Core.Types.SourceCacheContext cacheContext, NuGet.Common.ILogger log, System.Threading.CancellationToken token) [0x000f5] in <dc1b484fc03b4c9e94db6d2032a7a13d>:0
at NuGet.Protocol.Core.Types.PackageUpdateResource.PushPackageToServer (System.String source, System.String apiKey, System.String pathToPackage, System.Int64 packageSize, System.Boolean noServiceEndpoint, System.TimeSpan requestTimeout, NuGet.Common.ILogger logger, System.Threading.CancellationToken token) [0x00408] in <dc1b484fc03b4c9e94db6d2032a7a13d>:0
at NuGet.Protocol.Core.Types.PackageUpdateResource.PushPackageCore (System.String source, System.String apiKey, System.String packageToPush, System.Boolean noServiceEndpoint, System.TimeSpan requestTimeout, NuGet.Common.ILogger log, System.Threading.CancellationToken token, System.Boolean isSnupkgPush) [0x00176] in <dc1b484fc03b4c9e94db6d2032a7a13d>:0
at NuGet.Protocol.Core.Types.PackageUpdateResource.PushPackage (System.String packagePath, System.String source, System.String apiKey, System.Boolean noServiceEndpoint, System.TimeSpan requestTimeout, NuGet.Common.ILogger log, System.Threading.CancellationToken token, System.Boolean isSnupkgPush) [0x00124] in <dc1b484fc03b4c9e94db6d2032a7a13d>:0
at NuGet.Protocol.Core.Types.PackageUpdateResource.Push (System.String packagePath, System.String symbolSource, System.Int32 timeoutInSecond, System.Boolean disableBuffering, System.Func`2[T,TResult] getApiKey, System.Func`2[T,TResult] getSymbolApiKey, System.Boolean noServiceEndpoint, NuGet Protocol.Core.Types.SymbolPackageUpdateResourceV3 symbolPackageUpdateResource, NuGet.Common.ILogger log) [0x00107] in <dc1b484fc03b4c9e94db6d2032a7a13d>:0
at NuGet.Commands.PushRunner.Run (NuGet.Configuration.ISettings settings, NuGet.Configuration.IPackageSourceProvider sourceProvider, System.String packagePath, System.String source, System.String apiKey, System.String symbolSource, System.String symbolApiKey, System.Int32 timeoutSeconds, System.Boolean disableBuffering, System.Boolean noSymbols, System.Boolean noServiceEndpoint, NuGet.Common.ILogger logger) [0x002f3] in <dc1b484fc03b4c9e94db6d2032a7a13d>:0
at NuGet.CommandLine.PushCommand.ExecuteCommandAsync () [0x0016d] in <dc1b484fc03b4c9e94db6d2032a7a13d>:0
##[error]The nuget command failed with exit code(1) and error(Response status code does not indicate success: 403 (Forbidden - User 'GUID3' lacks permission to complete this action. You need to have 'AddPackage'. (DevOps Activity ID: GUID4)).)
##[error]Packages failed to publish
Finishing: Publishing package
我该如何解决这个问题?
更新,我已向提要授予以下权限,但没有成功。
确保在“存储库”>“您的存储库”>“安全”选项卡中,将“GUID3”用户添加到您的存储库安全性中,并将“贡献”设置为“允许”。
在您的管道中,添加 persistCredentials
steps:
- checkout: self
persistCredentials: true