【问题标题】:vNext Build pipeline to sync remote git into local repositoryvNext 构建管道以将远程 git 同步到本地存储库
【发布时间】:2018-09-13 11:43:13
【问题描述】:

我们在 BitBucket 中存储和处理了代码。我正在尝试使用构建管道将该代码同步到 VSTS Online 内的 git 存储库。但是,我不知道要使用哪些构建步骤从 BitBucket git 中提取文件并将它们推送到 VSTS git 中。

我的想法是这样的:

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

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

【问题讨论】:

    标签: git build azure-devops azure-pipelines vnext


    【解决方案1】:

    要将 Bitbucket 存储库的更改同步到 VSTS git 存储库,您可以添加 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:PAT@account.visualstudio.com/project/_git/repo
    git checkout $branch
    git push vsts $branch -f
    

    而类似情况,也可以参考How to sync repo in bitbucket to Visual studio team service的帖子。

    【讨论】:

    • 工作就像一个魅力。谢谢。
    猜你喜欢
    • 2011-09-16
    • 1970-01-01
    • 2014-10-19
    • 2017-09-23
    • 2018-11-30
    • 1970-01-01
    • 1970-01-01
    • 2015-12-16
    • 2012-02-22
    相关资源
    最近更新 更多