[英]Cannot push git tags in Azure Devops pipeline
我目前遇到了一個讓我非常困惑的問題。 我想通過 Azure Devops 構建管道標記 git 提交。 我遵循了本教程: https://elanderson.net/2020/04/azure-devops-pipelines-manual-tagging/我唯一不同的是使用 bash3BEF083D26881ZFAE01. (我也試過 PowerShell,但我得到了同樣的錯誤)
我得到的錯誤是:
我的構建定義在這里
variables:
BuildConfiguration: release
BuildPlatform: 'any cpu'
stages:
- stage: DeployArtifacts
jobs:
- job: TagSources
displayName: 'Tag Sources'
pool:
vmImage: 'ubuntu-20.04'
steps:
- checkout: self
persistCredentials: true
clean: true
fetchDepth: 1
- task: Bash@3
inputs:
targetType: 'inline'
failOnStderr: false
script: |
#pwd
#ls -alR
Version="1.00"
echo "Tagging branch with $Version"
git tag $(Version)
echo "Successfully tagged branch"
git push --tags
echo "Pushed tag to branch $Version"
我還按照本文中的建議向構建帳戶添加了貢獻權限( Azure 管道不允許 git 推送需要“GenericContribute”權限),但我仍然遇到相同的錯誤。 我不確定我還能嘗試什么。
任何幫助深表感謝。 謝謝
如果您對標記哪些分支/提交沒有任何特定規則,您可以將管道設置為在完成構建時自動添加標記
與此同時,我自己設法解決了這個問題。 它不是很漂亮,但它有效。 我注釋掉了persistCredentials: true
並在 git 存儲庫的來源中添加了 PAT。
# Fix as persistCredentials is not returning the desired result
REMOTE_NAME=$(git remote get-url origin)
echo "Remote name: $REMOTE_NAME"
NEW_REMOTE="${REMOTE_NAME//https:\/\/XXXXX@/https:\/\/XXXXX:$(PAT)@}"
echo "New Remote name: $NEW_REMOTE"
git remote set-url origin $NEW_REMOTE
Push 現在可以正常工作了。
我不確定為什么建議的更改在我的 Azure Devops 帳戶中不起作用。 無論如何,感謝您的幫助和回答。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.