DIG*_*JSS 2 bitbucket bitbucket-api azure-devops azure-pipelines azure-devops-rest-api
我是VSTS平台的新手.在我的一个项目中,我试图将bitbucket源代码控制集成到VSTS.通过这种方式,我应该能够看到bitbucket上的更新到VSTS帐户上.
我尝试过在VSTS上创建构建,但这只显示了所选的bitbucket存储库的提交历史记录.
有没有办法管理VSTS上的所有bitbucket更改作为源代码控制?
要自动将bitbucket repo中的更改同步到VSTS git repo,您可以使用VSTS构建定义来实现它.详细步骤如下:
创建VSTS构建定义时 - >选择要同步的Bitbucket存储库 - >创建.
在构建定义 - >触发器选项卡 - >启用持续集成 - >包括所有分支*.
使用以下脚本添加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:PAT@account.visualstudio.com/project/_git/repo
git checkout $branch
git push vsts $branch -f
Run Code Online (Sandbox Code Playgroud)
有关添加和配置PowerShell任务的详细步骤,如下所示:
编辑构建定义 - >单击+为代理阶段添加任务 - >搜索powershell任务 - >单击添加 - >单击您添加的PowerShell任务 - >选择内联类型 - >然后在脚本选项中添加您的powershell脚本 - >保存构建定义.
现在无论你的bitbucket repo中更新了哪个分支,VSTS git repo都会自动同步.
Yo同步从VSTS git repo更改为bitbucket repo,您可以创建另一个CI构建来实现它.详细步骤如下:
2.启用持续集成
3.使用以下方面添加PowerShell任务
if ( $(git remote) -contains 'bitbucket' )
{git remote rm bitbucket
echo 'remove remote bitbucket'
}
git remote add bitbucket https://username:password@bitbucket.org/username/repo.git
$branch="$(Build.SourceBranch)".replace("refs/heads/","")
git checkout $branch
git push bitbucket $branch -f
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5150 次 |
| 最近记录: |