我对VSTS平台非常陌生。在我的项目之一中,我试图将位桶源代码控制集成到VSTS。通过这种方式,我应该可以在VSTS帐户上看到对Bitbucket所做的更新。
I am very new to VSTS platform. In one of my project, I am trying to integrate the bitbucket source control to VSTS. By this way I should be able to see the updates made on bitbucket onto the VSTS account.
我尝试在VSTS上创建构建,但是仅显示了的提交历史记录。
I have tried creating build on VSTS, but that only shows the commits history of the selected repository of bitbucket.
是否有一种方法可以管理VSTS上的所有位桶更改作为源代码控制?
Is there a way to manage all the bitbucket changes on VSTS as source control?
推荐答案要自动将位桶存储库中的更改同步到VSTS git存储库中,可以使用 VSTS构建定义来实现。详细步骤如下:
To sync changes from bitbucket repo to VSTS git repo automatically, you can achieve it by using a VSTS build definition. Detail steps as below:
创建VSTS构建定义时->选择要同步的Bitbucket存储库->创建。
When creating a VSTS build definition -> Select the Bitbucket repo you want to sync -> create.
在构建定义中->触发器选项卡->启用持续集成->包括所有带有 * 。
In the build definition -> Triggers Tab -> Enable continuous integration -> Include all branches with *.
使用以下脚本添加PowerShell任务:
Add a PowerShell task with below script:
if ( $(git remote) -contains 'vsts' ) {git remote rm vsts echo 'remove remote vsts' } $branch="$(Build.SourceBranch)".replace("refs/heads/","") git remote add vsts Personal%20Access%20Token:PAT@account.visualstudio/project/_git/repo git checkout $branch git push vsts $branch -f有关添加和配置PowerShell任务的详细步骤,如下所示:
For the detail steps to add and config the PowerShell task as below:
编辑构建定义->单击 + 为您的代理阶段添加任务->搜索powershell任务->单击添加->单击添加的PowerShell任务->选择内联类型->然后在脚本选项中添加powershell脚本->保存构建定义。
Edit your build definition -> Click + to add a task for your agent phase -> Search powershell task -> click Add -> click the PowerShell task you added -> select Inline type -> then add your powershell script in the Script option -> Save build definition.
现在,无论您的位桶存储库中哪个分支已更新,VSTS git存储库都将自动同步。
Now no matter which branch is updated in your bitbucket repo, VSTS git repo will be synced automatically.
Yo sync从VSTS git repo更改为bitbucket repo,您可以创建另一个CI构建来实现它。详细步骤如下:
Yo sync changes from VSTS git repo to bitbucket repo, you can create another CI build to achieve it. Detail steps as below:
2.启用持续集成 3.添加具有以下方面的PowerShell任务
2. Enable continuous integration 3. Add a PowerShell task with below aspects
if ( $(git remote) -contains 'bitbucket' ) {git remote rm bitbucket echo 'remove remote bitbucket' } git remote add bitbucket username:password@bitbucket/username/repo.git $branch="$(Build.SourceBranch)".replace("refs/heads/","") git checkout $branch git push bitbucket $branch -f更多推荐
如何将Bitbucket中的存储库同步到Visual Studio团队服务?
发布评论