Azure DevOps:用户无权完成此操作。你需要 'AddPackage'

Azure DevOps: User lacks permission to complete this action. You need to have 'AddPackage'

我收到一个错误:

User XXX lacks permission to complete this action. You need to have 'AddPackage'

尝试将 nuget 包推送到 Azure DevOps 项目时。我是管理员 这是舞台:

  - stage:
    displayName: 'Release'
    condition: succeeded()
    jobs:
      - job: 'Publish'
        displayName: 'Publish nuGet Package'
        steps:
          - download: current
            artifact: $(PIPELINE_ARTIFACT_NAME)
            displayName: 'Download pipeline artifact'
          - script: ls $(PATH_PIPELINE_ARTIFACT_NAME)
            displayName: 'Display contents of downloaded articacts path'
          - task: NuGetAuthenticate@0
            displayName: 'Authenticate in NuGet feed'
          - script: dotnet nuget push $(PATH_PIPELINE_ARTIFACT_NAME)/**/*.nupkg --source $(NUGET_FEED) --api-key $(NUGET_API_KEY)
            displayName: 'Uploads nuGet packages'

准确的错误:

error: Response status code does not indicate success: 403 (Forbidden - User '4a2eb786-540d-4690-a12b-013aec2c86e5' lacks permission to complete this action. You need to have 'AddPackage'. (DevOps Activity ID: XXXXXXX-6DF9-4A98-8A4E-42C556C6FC56)).
##[error]Bash exited with code '1'.
Finishing: Uploads nuGet packages

git 存储库在 GitHub 中。不确定谁被认为是用户,但我不知道要修改哪些其他权限

我似乎通过将 Build Service as Contributor 添加到 Feed 的权限设置来修复。

这有点令人困惑,但现在可以正常工作了。

伟大的发现!在 ... 菜单中允许项目范围内的构建对我有用。

但是为了能够将包从 Azure Pipelines 推送到 Azure Artifacts 提要,我必须在 dotnet build 和最后的 dotnet push 之前的 dotnet restore 步骤下添加与 Target 提要相同的提要。 https://docs.microsoft.com/en-us/azure/devops/artifacts/nuget/dotnet-exe?view=azure-devops

对于像我一样完全迷路的人,@diegosasw 所说的页面在 Artifacts 菜单中,而不是在 Task 或 Pipeline 中:

步骤:

  1. 点击左侧的Artifacts
  2. Select 下拉列表中的供稿(通常默认选择)
  3. 点击右上角的进给设置齿轮。
  4. 单击权限
  5. 单击 添加 Users/groups 并搜索 {您的组织} 构建服务 并添加为 贡献者.

正确的答案是,在工件设置页面(您可以按照上面的解释访问)您需要为名称模式为 [project_name] Build Service 的用户添加贡献者权限。例如,如果您的项目名称是“IoT”,您需要在权限选项卡中的添加user/groups找到用户“IoT Build Service”,如上所示,并分配贡献者权限。

如果仍然出现错误,您也可以尝试将团队添加为贡献者。

希望有用。

[project_name][project_name] 团队 - 贡献者

project_name 构建服务(Org_name) - 贡献者