繁体   English   中英

从 Azure Devops 管道访问私有源

[英]Access to private feed from Azure Devops pipeline

我想从管道(项目 A)创建对我的私人提要的访问,但是每次我尝试运行dotnet restore以使用来自私人提要的 nugets 恢复 .net 项目(项目 B 中的项目范围提要)时,我得到了

error NU1301: Unable to load the service index for source <<url_to_my_feed>>

我的 pipeline.yml 看起来像:

[previous jobs]

- task: NuGetAuthenticate@0

- task: Docker@2
  displayName: Build image
  inputs:
    command: build
    containerRegistry: $(dockerRegistryServiceConnection)
    repository: $(contentHostRepositoryName)
    Dockerfile: "$(Build.SourcesDirectory)/src/modules/content/src/Dockerfile"
    arguments: '--build-arg PAT=$(VSS_NUGET_ACCESSTOKEN)'
    tags: |
       $(tag)

[next jobs]

我的 dockerfile 看起来像:

...
ARG PAT
RUN dotnet nuget add source <<url_to_my_feed>> --name <<name>> --username <<username>> --password $PAT --store-password-in-clear-text
...

当我将'--build-arg PAT=$(VSS_NUGET_ACCESSTOKEN)'替换为'--build-arg PAT=<<pat_token>>'其中<<pat_token>>是令牌时,我在 Azure 中为我的个人帐户生成手册Devops -everythink 工作正常。

我尝试什么:

  • 使用 $(System.AccessToken) 代替 $(VSS_NUGET_ACCESSTOKEN)
  • 在项目 A 构建服务的提要集贡献权限中
  • 在项目 B 中禁用Limit job authorization scope to current project for non-release pipelines ,并将Limit job authorization scope to current project for release pipelines
  • 使用NuGetAuthenticate@0NuGetAuthenticate@1
  • 进入项目 A 中的管道安全性允许为每个人提供项目构建服务
  • 在使用 $(System.AccessToken) main 进入变量之前

添加Project Collection Build Service (Organization)并使其具有相关权限。

在此处输入图像描述

由于您使用 yml 文件管道,并且您禁用Limit job authorization scope to current project for non-release pipelines ,因此项目构建服务帐户将更改为项目集合构建服务帐户。

请使用 $(System.AccessToken) 进行身份验证。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM