簡體   English   中英

從 Azure 發布管道執行 Git 推送

[英]Doing Git Pushes from the Azure Release Pipeline

我想在自托管構建服務器的 Azure Devops 發布管道中從 powershell 腳本執行 git push。

它在構建管道中工作,但在發布管道中我最終遇到了身份驗證錯誤。 “允許腳本訪問 OAuth 令牌”被激活並且構建機器具有貢獻權限(正如我所說,它在構建管道中工作)。

這是我在 devops protal 中看到的錯誤:

git : remote: 001f# service=git-receive-pack
At C:\Builds\A1\_work\r1\a\Source\Scripts\CreateTagFromPipeline.ps1:11 char:1
+ git push
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (remote: 001f# service=git-receive-pack:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

PowerShell exited with code '1'.

如果我通過遠程桌面登錄我的機器並手動推送,我會得到一些更好的錯誤:

$ git push
remote: 001f# service=git-receive-pack
remote: 0000000000aaTF401027: You need the Git 'GenericContribute' permission to perform this action. Details: identity 'Build\58bb64d7-d065-4522-94e2-a153b9fdadd6', scope 'repository'.
remote: TF401027: You need the Git 'GenericContribute' permission to perform this action. Details: identity 'Build\58bb64d7-d065-4522-94e2-a153b9fdadd6', scope 'repository'
fatal: unable to access 'https://our-correct-repo-address-on-dev.azure.com': The requested URL returned error: 403

同樣,它適用於構建管道,但不適用於發布管道。

-- 開始編輯 -- 您需要授予此身份“Build**58bb64d7-d065-4522-94e2-a153b9fdadd6**”的通用貢獻權限。

  1. 在 azure devops 中轉到項目設置
  2. 轉到 repos -> repositories -> 點擊你的 repo
  3. 在安全選項卡上,在“搜索用戶和組”中瀏覽 ID 58bb64d7-d065-4522-94e2-a153b9fdadd6
  4. 點擊找到的身份並確保其具有:貢獻權限、創建分支、創建標簽和讀取權限設置為允許

- - 編輯 - -

構建管道是否也在自托管構建服務器上運行?

轉到您的構建管道 -> 變量 -> 檢查 system.collectionId。

是 58bb64d7-d065-4522-94e2-a153b9fdadd6 嗎?

如果這不是您構建管道中的集合 ID,則表示您的發布管道中的標識 58bb64d7-d065-4522-94e2-a153b9fdadd6 沒有創建分支的權限。

Azure DevOps Pipelines 中可能涉及不同的帳戶。 在組織級別,您擁有“項目集合構建服務 (YourOrg)”,在項目級別,您擁有“您的項目構建服務 (YourOrg)”。

其中哪一個用於構建取決於管道選項“構建作業授權范圍”是否設置為“項目集合”或“當前項目”。 目前似乎沒有發布管道的相應選項,默認為項目集合構建服務。

我猜“Build\58bb64d7-d065-4522-94e2-a153b9fdadd6”是您的項目集合構建服務,但您只授予了對項目構建服務的貢獻權限,並且在構建管道上使用范圍“當前項目”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM