使用 Azure DevOps 从一个存储库构建多个项目

Build several projects from one repository with Azure DevOps

我们在 GitLab 上托管了一个 Java/Spring Boot/React 项目。在初步开发之后,我们决定迁移到 Azure DevOps。托管在 GitLab 和本地文件夹结构中的项目结构很简单:

-- Parent project (parent folder)
------- First Spring Boot Project (built with Maven, produces JAR1)
------- Second Spring Boot Project (built with Maven, uses JAR1 as dependency, produces JAR2)
------- React project (built with NPM, produces static pages)

我需要为 React 和 Spring 1 和 2 项目设置单独的构建过程。 在 Azure DevOps 中有用于从特定分支构建的选择器,但我不知道如何设置管道以从特定文件夹构建项目?

您有路径过滤器:

# specific path build
trigger:
  branches:
    include:
    - master
    - releases/*
  paths:
    include:
    - docs/*
    exclude:
    - docs/README.md

请检查文档here

  1. 当您使用 Maven 任务构建 Spring 引导项目时,您需要通过更改 Maven POM 文件字段的值来指定 pom.xml 文件的路径。文件路径值应相对于存储库的根目录,例如 IdentityService/pom.xml 或 $(system.defaultWorkingDirectory)/IdentityService/pom.xml。 这是关于 Maven task.
  2. 的文档
  3. 当您使用 npm task 构建您的 React 项目时,您可以设置包含 package.json 的工作文件夹。设置工作文件夹时请select文件夹而不是文件。 这是关于 npm task.
  4. 的文档

此外,您可能还需要在持续集成(CI)触发器中设置路径过滤器。这是关于 CI Triggers.

的文档