我们在BitBucket中存储并处理了代码。我试图通过使用构建管道将该代码同步到VSTS Online中的git存储库。但是,我无法弄清楚使用什么构建步骤来从BitBucket git中提取文件并将它们推入VSTS git。
我的想法是这样的:
“获取源”从远程BitBucket存储库中获取文件,然后命令行脚本意味着通过首先切换到主分支然后从远程git拉取来将它们保存到本地VSTS git。但是,我不确定要用于此任务的命令和/或作业模块。
图片来自Build and release选项卡下的本地VSTS git repo。
要将Bitbucket repo中的更改同步到VSTS git repo,您可以添加PowerShell任务来实现它。
PowerShell脚本如下:
if ( $(git remote) -contains 'vsts' )
{git remote rm vsts
echo 'remove remote vsts'
}
$branch="$(Build.SourceBranch)".replace("refs/heads/","")
git remote add vsts https://Personal%20Access%20Token:[email protected]/project/_git/repo
git checkout $branch
git push vsts $branch -f
对于类似的情况,你也可以参考邮政How to sync repo in bitbucket to Visual studio team service。