vNext构建管道以将远程git同步到本地存储库

问题描述 投票:0回答:1

我们在BitBucket中存储并处理了代码。我试图通过使用构建管道将该代码同步到VSTS Online中的git存储库。但是,我无法弄清楚使用什么构建步骤来从BitBucket git中提取文件并将它们推入VSTS git。

我的想法是这样的:

enter image description here

“获取源”从远程BitBucket存储库中获取文件,然后命令行脚本意味着通过首先切换到主分支然后从远程git拉取来将它们保存到本地VSTS git。但是,我不确定要用于此任务的命令和/或作业模块。

图片来自Build and release选项卡下的本地VSTS git repo。

git build azure-devops azure-pipelines vnext
1个回答
1
投票

要将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

© www.soinside.com 2019 - 2024. All rights reserved.