gpt4 book ai didi

azure - 在 Azure DevOps 中检查多个项目时如何构建正确的项目

转载 作者:行者123 更新时间:2023-12-03 02:15:19 24 4
gpt4 key购买 nike

我正在阅读此文档: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_VNext\Agent2_Builds\3046\s

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

关于azure - 在 Azure DevOps 中检查多个项目时如何构建正确的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71605350/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com