Github Actions构建Tibco应用报错:当前目录无POM文件
Github Actions构建Tibco应用时Maven找不到POM文件的解决方法
问题场景
为Tibco应用搭建CI/CD流程,使用的Github Actions配置如下:
name: DEV workflow on: push: branches: [ "dev" ] pull_request: branches: [ "dev" ] jobs: build: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 - name: Set up JDK 11 uses: actions/setup-java@v3 with: java-version: '11' distribution: 'temurin' cache: maven - name: Build with Maven run: mvn clean # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Update dependency graph uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
执行时Build with Maven步骤失败,错误信息:
[INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.066 s [INFO] Finished at: 2023-02-07T17:03:24Z [INFO] ------------------------------------------------------------------------ Error: The goal you specified requires a project to execute but there is no POM in this directory (/home/runner/work/tibco-sample/tibco-sample). Please verify you invoked Maven from the correct directory. -> [Help 1] Error: Error: To see the full stack trace of the errors, re-run Maven with the -e switch. Error: Re-run Maven using the -X switch to enable full debug logging. Error: Error: For more information about the errors and possible solutions, please read the following articles: Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException Error: Process completed with exit code 1.
无法直接查看Runner上的目标目录,需按以下步骤排查解决:
解决步骤
1. 先确认仓库中POM文件的位置
检查你的Github代码仓库,确认pom.xml是否在仓库根目录,还是存放在某个子目录下。Maven默认会在当前执行目录查找POM文件,若文件不在根目录则会触发该错误。
2. 添加目录检查步骤定位问题
在Checkout repository步骤之后,新增一个列出目录内容的步骤,通过Actions日志确认代码是否正确检出、POM文件的位置:
- name: List directory contents run: ls -la
3. 调整Maven执行路径
如果POM文件在子目录(例如./tibco-module),可以通过两种方式修正:
- 指定Maven的工作目录:
- name: Build with Maven run: mvn clean working-directory: ./tibco-module
- 直接在命令中指定POM文件路径:
- name: Build with Maven run: mvn clean -f ./tibco-module/pom.xml
4. 确认代码检出完整性
如果仓库包含子模块,需要在Checkout步骤中开启子模块拉取:
- name: Checkout repository uses: actions/checkout@v2 with: submodules: true
内容的提问来源于stack exchange,提问作者Niladri Dey
相关产品推荐
相关产品推荐

