【问题标题】:Build several projects from one repository with Azure DevOps使用 Azure DevOps 从一个存储库构建多个项目
【发布时间】:2020-09-27 17:56:38
【问题描述】:

我们在 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 中有用于从特定分支构建的选择器,但我看不到如何设置管道以从特定文件夹构建项目?

【问题讨论】:

  • 为什么它们在同一个git仓库,你却要分开构建?
  • @JFabianMeier 因为 Spring Boot 是用 Maven 构建的,而 React 是用 NodeJS 构建的,所以我需要两个单独的管道。此外,对于项目 1 和项目 2,必须在父项目之前构建。为什么所有这些项目都在同一个 Git 存储库中?为了避免开发人员提交后端部分但忘记前端或反之亦然的常见错误。还将所有依赖项保存在同一个存储库中,便于维护。
  • @JFabianMeier 类似这样,但用于 Azure DevOps stackoverflow.com/questions/41182186/…
  • 请检查以下几个答案是否可以解决您的问题。如果您仍然被阻止,请随时告诉我,我会尽力提供帮助。

标签: reactjs spring-boot maven azure-devops devops


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

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

【讨论】:

    【解决方案2】:

    你有路径过滤器:

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

    请查看文档here

    【讨论】:

      猜你喜欢
      • 2019-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-07
      • 1970-01-01
      • 2019-11-06
      • 1970-01-01
      • 2021-06-06
      相关资源
      最近更新 更多