Azure devops Azure DevOps推送至GitLab

Azure devops Azure DevOps推送至GitLab,azure-devops,gitlab,devops,gitlab-ci,gitlab-api,Azure Devops,Gitlab,Devops,Gitlab Ci,Gitlab Api,在Azure DevOps中,我试图创建一个命令行脚本,将实际的DevOps Repo推送到GitLab git clone https://xxxx@dev.azure.com/xxxx/DBS/_git/xxx git remote add --mirror=fetch secondary https://oauth2:%pat%@gitlab.com/username/gitlabrepo.git git fetch origin git push secondary --all 在环境

在Azure DevOps中,我试图创建一个命令行脚本,将实际的DevOps Repo推送到GitLab

git clone https://xxxx@dev.azure.com/xxxx/DBS/_git/xxx
git remote add --mirror=fetch secondary https://oauth2:%pat%@gitlab.com/username/gitlabrepo.git
git fetch origin
git push secondary --all
在环境参数%pat%中,我引用了GitLab中的个人访问令牌。 使用Comman Line脚本运行管道时,我遇到以下错误:

start to push repo to gitlab
Cloning into 'gitlabrepo'...
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.com/***/gitlabrepo.git/'
##[debug]Exit code: 128
##[debug]Leaving Invoke-VstsTool.
##[error]Cmd.exe exited with code '128'.
如何做到这一点

  • 确保这些命令在git bash中本地工作
  • 运行
    git config--global--unset credential.helper
    command
    git add
    command
  • 如果问题仍然存在,请尝试运行git remote set url originhttps://usernameHere:personalAccessTokenHere@gitlab.com/usernameHere/projectNameHere
  • 如果使用自托管代理,请转到代理计算机,并在凭据管理器中删除凭据

  • Avure DevOps代理正在ubuntu-18.04机器上运行此功能。似乎使用PAT连接到gitlab失败,因为这是一个公司gitlab帐户,并且有一些防火墙限制。因为从我的本地计算机通过VPN连接到公司网络,它正在工作。Git bash在本地运行良好。错误是因为管道代理启动的此计算机未进入公司的VPN。

    您使用microsoft hosted Agent还是自托管Agent运行管道?@CeceDong MSFT Avure DevOps Agent正在ubuntu-18.04计算机上运行此程序。似乎使用PAT连接到gitlab失败了,因为这是一个公司gitlab帐户,并且有一些防火墙限制。我的假设。因为从我的本地机器通过VPN连接到公司网络,它正在工作。如果你在这个ubuntu-18.04机器上用git bash运行命令,结果如何?@CeceDong MSFT git bash local工作正常。错误是因为管道代理启动的此计算机未进入公司的VPN。>致命:无法访问“”:无法解决主机:公司问题解决后,您可以添加答复并将其接受为答复,这对阅读此线程的其他社区成员有益。