[英]Use VSTS Continous Integration Pipeline with Projects From Different Git Repositories
I have this particiular setup that I would like to include into VSTS and continous integration + continous deployment.我有这个特定的设置,我想将其包含到 VSTS 和持续集成 + 持续部署中。 For the sake of simplicity, I'll reduce my situation to the following setup:为简单起见,我将我的情况简化为以下设置:
I have two solutions, A and B, which are in individual Git repositories.我有两个解决方案 A 和 B,它们位于单独的 Git 存储库中。 One project A1 of solution A references a project B1 of solution B. Since this is a simplified case for demonstration purposes, let's assume that the Git repositories can not be merged!解决方案 A 的一个项目 A1 引用了解决方案 B 的项目 B1。由于这是一个用于演示目的的简化案例,我们假设 Git 存储库无法合并!
Right now, I'm setting up CI for project A1.现在,我正在为项目 A1 设置 CI。 The project's build obviously fails since the dependencies to B1 can't be resolved.项目的构建显然失败了,因为无法解决对 B1 的依赖。
So far I've googled two solutions for my case which both make me unhappy:到目前为止,我已经为我的案例搜索了两个解决方案,这两个解决方案都让我不高兴:
I will also set up a CI pipeline for B1 in VSTS.我还将在 VSTS 中为 B1 设置 CI 管道。
I guess I'm looking for a way to using a "reference path" for VSTS to look for dependencies that I build from another CI pipeline.我想我正在寻找一种方法来使用 VSTS 的“参考路径”来查找我从另一个 CI 管道构建的依赖项。 Is there a sort of shared "bin" space for VSTS projects? VSTS 项目是否有一种共享的“bin”空间? Before A1's build, I would automatically copy the built binary from B1 to A1.在 A1 构建之前,我会自动将构建的二进制文件从 B1 复制到 A1。
Is there any good way to achieve this?有什么好的方法可以实现这一目标吗? Right now I'm thinking about a post/pre-build FTP/cloud push/pull solution but given my situation (dependencies over different Git repositories) should be pretty common, what is the solution?现在我正在考虑一个 post/pre-build FTP/cloud push/pull 解决方案,但考虑到我的情况(对不同 Git 存储库的依赖)应该很常见,解决方案是什么?
If you do not want to manage the projectB1
by NuGet package, there has other options you can use.如果您不想通过 NuGet 包管理projectB1
,您可以使用其他选项。
Assume solutionB
is managed in repoB
and file structure in repoB
look like:假设solutionB
在管理repoB
和文件结构repoB
的样子:
repoB
|___solutionB
|___projectB1
|___...
|___...
|___...
At the beginning of your build definition, you can add a PowerShell task to clone repo.在构建定义的开头,您可以添加一个PowerShell 任务来克隆存储库。 The PowerShell script as below: PowerShell 脚本如下:
# If you are using private agent to build and clean source is false, you should check if the repoB folder exist or not
git clone https://Personal%20Access%20Token:{PAT}@{account}.visualstudio.com/{project}/_git/repoB
To make sure solutionB
build firstly, you can use two VS build task.为了确保solutionB
首先构建,您可以使用两个VS构建任务。 The firstly one used for building solutionB
( repoB/*.sln
), and the second one used for building solutionA
( **/solutionA.sln
).第一个用于构建solutionB
( repoB/*.sln
),第二个用于构建solutionA
( **/solutionA.sln
)。
If you want to add repoB
as submodule for repoA
, then you can add repoB
as submodule for repoA
by:如果要将repoB
添加为repoA
子模块,则可以通过以下方式将repoB
添加为repoA
的子模块:
git submodule add https://{account}.visualstudio.com/{project}/_git/repoB
Then commit and push the changes to remote repoA
.然后提交并将更改推送到远程repoA
。
Note: you also need to added another VS Build task to build solutionB firstly,.注意:您还需要添加另一个 VS Build 任务来首先构建 solutionB,。
Similar as submoodule, you can add a branch (such as master
) of repoB
into repoA
by:与 submoodule 类似,您可以通过以下方式将 repoB 的一个分支(例如master
) repoB
到repoA
:
git subtree add --prefix=repoB https://{account}.visualstudio.com/{project}/_git/repoB master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.