簡體   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