在Azure devops中检查多个项目时,我如何构建正确的项目



我正在阅读此文档:https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops

根据上面的链接,我们可以在一个管道中有多个项目。所以我有这样的东西:

trigger:
- none
resources:
repositories:
- repository: repo1
type: git
name: org/repo1
ref: test_multi_repo_pipeline
trigger:
- test_multi_repo_pipeline
- repository: repo2
type: git
name: org/repo2
ref: test_multi_repo_pipeline
trigger:
- test_multi_repo_pipeline  
stages:
- stage: Build_and_Deploy
pool:
name: 'myAgent'
jobs:
- job: Build
condition: always()
steps:
- checkout: repo1
displayName: 'repo1'
- checkout: repo2
displayName: 'repo2'

- script: dir $(Build.SourcesDirectory)
displayName: 'Build.SourcesDirectory'

- script: |
npm run build:project_win_dev
displayName: Building the project...
- script: |
npm run test:coverage
displayName: Testing the skill...

- script: dir $(Build.SourcesDirectory)
displayName: 'Build.SourcesDirectory'
name: Test

所以当我执行这个yaml时,我得到这个任务的下一个输出";Build.SourcesDirectory":

Directory of E:Builds_VNextAgent2_Builds3046s
03/24/2022  11:24 AM    <DIR>          .
03/24/2022  11:24 AM    <DIR>          ..
03/24/2022  11:24 AM    <DIR>          pipelines
03/24/2022  11:24 AM    <DIR>          repo1
03/24/2022  11:24 AM    <DIR>          repo2
0 File(s)              0 bytes
5 Dir(s)  878,801,965,056 bytes free

所以一旦";构建";任务执行失败,因为它是在根目录中执行的,而不是在我提交的特定项目中执行的。所以我想知道是否有一种方法可以知道,如果我在项目repo1中进行了提交,那么构建就在文件夹repo1下完成,如果我对repo2进行了更改,那么构建就会在repo2文件夹内完成

提前感谢您的帮助。

问候

因此,可以编写一个条件来确定您正在编辑的回购。但是,我建议不要这样做。你必须查询git历史记录并检测更改。

抵制租赁的途径是每次都建立两者。在构建之前,您只需要将代码更新到cd的正确文件夹中

trigger:
- none
resources:
repositories:
- repository: repo1
type: git
name: org/repo1
ref: test_multi_repo_pipeline
trigger:
- test_multi_repo_pipeline
- repository: repo2
type: git
name: org/repo2
ref: test_multi_repo_pipeline
trigger:
- test_multi_repo_pipeline  
stages:
- stage: Build_and_Deploy
pool:
name: 'myAgent'
jobs:
- job: Build
condition: always()
steps:
- checkout: repo1
displayName: 'repo1'
- checkout: repo2
displayName: 'repo2'

- script: dir $(Build.SourcesDirectory)
displayName: 'Build.SourcesDirectory'

- script: |
cd repo1
ls
echo '----'
npm run build:project_win_dev
echo 'Running Tests'
npm run test:coverage
displayName: 'Build and Test: Repo 1'
- script: |
cd repo2
ls
echo '----'
npm run build:project_win_dev
echo 'Running Tests'
npm run test:coverage
displayName: 'Build and Test: Repo 2'

- script: dir $(Build.SourcesDirectory)
displayName: 'Build.SourcesDirectory'
name: Test

相关内容

  • 没有找到相关文章

最新更新