Maven 项目构建过程中出现“No file in /home/runner/work/...matched to [**/pom.xml]”错误

问题描述 投票:0回答:1

我创建了一个基于 Maven 的测试自动化框架,并已将其推送到我的 GitHub 存储库中的“开发”分支。 每次创建 PR 时都需要构建我的项目。因此,我创建了一个 build.yaml 文件并将其添加到我的存储库中。但是当我创建一个新的 PR 时,构建过程会因为这个问题而失败:

Error: No file in /home/runner/work/report-portal/report-portal matched to [**/pom.xml], make sure you have checked out the target repository

这是我的 build.yaml 文件:

name: Build and Test

on:
  push:
    branches: [ "master", "develop" ]
  pull_request:
    branches: [ "master", "develop" ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - run: ls -la
    - name: Set up JDK 20
      uses: actions/setup-java@v3
      with:
        java-version: '20'
        distribution: 'temurin'
        cache: maven
    - name: Build with Maven
      run: mvn clean test --file POM.xml
      working-directory: ${{github.workspace}}

我将此行

- run: ls -la
添加到 build.yaml 中,并可以在日志中看到我的 POM.xml 文件可见: GitHub logs 1

再次,根据日志,我的存储库已成功签出: Git Hub logs 2

有什么办法找不到我的 POM 文件吗?

java maven github automation pom.xml
1个回答
0
投票

mvn clean test --file POM.xml
?在 Maven 中,
pom.xml
文件区分大小写,并且应完全命名为
pom.xml
而不是
POM.xml
。在您提供的
build.yaml
文件中,您引用的是
POM.xml
而不是
pom.xml

您应该修改此行以小写引用

pom.xml
,如下所示:

    - name: Build with Maven
      run: mvn clean test --file pom.xml
      working-directory: ${{github.workspace}}

该更改指示 Maven 查找

pom.xml
,这应该可以解决您在构建过程中遇到的错误。

© www.soinside.com 2019 - 2024. All rights reserved.