任何人都可以帮助我如何在我的构建管道中运行 git 命令。我想在开始构建部署解决方案之前将我的开发分支合并到暂存分支。我已经添加命令行任务并运行 git 命令,但它没有从 GIT 给出任何结果
问问题
2837 次
4 回答
3
这是我直接在 yaml 管道 bash 命令中完成与 git repo 交互的方式
cd $(Agent.BuildDirectory)/s
# Update Git User
git config --global user.email $(GITHUB_EMAIL)
git config --global user.name $(GITHUB_NAME)
# Switch to clone from branch
git checkout -b $(FROM_BRANCH) origin/$(FROM_BRANCH)
# do your code manipulations here then push them upstream
git push origin -f $(TO_BRANCH)
于 2020-06-15T08:01:58.910 回答
0
我想将我的开发分支合并到暂存分支
您可以尝试使用git merge
命令进行合并。
这是一个例子:
git remote add Reponame https://PAT@dev.azure.com/orgNAME/project name/_git/Reponame
git checkout -b staging
git pull
git merge remotes/origin/dev
git push Reponame staging -f
您可以直接在Command Line Task
.
然后Dev branch
将合并到Staging branch
.
您可以获得以下构建日志。
希望这可以帮助。
于 2020-06-16T07:13:59.053 回答
0
通常,您有两条管道,一条用于 PR,检查您的所有更改是否编译没有错误,然后编译和发布工件的 CI 构建,如果您没有发布,则进行部署。
所以只有在 Master 分支发生变化时才会触发 CI 构建。因此,您不必将合并作为一项任务,您必须进行合并,然后启动构建管道。
于 2020-06-15T07:42:36.130 回答
0
自从问了这个问题已经有一段时间了。但我想为那些寻求在管道中 git checkout 之前运行代码的人介绍一种替代方法(来自官方文档中的示例):
steps:
- script: |
git config --global --add filter.lfs.required true
displayName: Configure LFS for use with submodules
- checkout: self
于 2020-12-29T12:03:47.443 回答