本地正常运行的build.gradle在GitLab CI Runner中执行失败
本地环境
- 基于
adoptopenjdk:11-jdk镜像运行Docker容器 - 容器内执行仅包含
gradlew check的脚本./scripts/bash/run_plugin_tests.sh - 构建成功,测试正常执行
GitLab服务器环境
- 使用Docker执行器的GitLab CI Runner
- 对应的
.gitlab-ci.yml配置如下:
stages: - test - deploy variables: GRAILS_OPTS: -Xms512m -Xmx512m DEPLOYMENT: CI test_plugin: image: adoptopenjdk:11-jdk stage: test script: - ./scripts/bash/run_plugin_tests.sh artifacts: when: always expire_in: 7d reports: junit: - ./build/test-results/test/*.xml paths: - ./build/reports/tests/* deploy_plugin: image: adoptopenjdk:11-jdk stage: deploy script: - ./scripts/bash/deploy_plugin.sh dependencies: - test_plugin #Only on master branch only: - main
- Runner初始化启动容器的日志如下:
Running with gitlab-runner 15.6.1 (133d7e76) on EC2-Gitlab-runner(Instance : i-0b35b804ea5d8f6d7) zpxfwm-E Preparing the "docker" executor 00:02 Using Docker executor with image adoptopenjdk:11-jdk ... Pulling docker image adoptopenjdk:11-jdk ...
- 构建测试阶段失败,报错为找不到或无法加载主类,Gradle Test Executor进程退出值非零
问题排查与解决
- 该问题仅在GitLab CI环境出现,本地执行无异常;GitLab CI Runner可正常运行其他项目
- 项目为Grails插件,经排查发现是GitLab CI中
GRAILS_OPTS变量内-Xms512m与-Xmx512m之间有两个空格,导致Grails 4.0.5解析失败 - 将空格改为单个后,构建成功,修改后的
.gitlab-ci.yml配置如下:
stages: - test - deploy variables: GRAILS_OPTS: -Xms512m -Xmx512m DEPLOYMENT: CI test_plugin: image: adoptopenjdk:11-jdk stage: test script: - ./scripts/bash/run_plugin_tests.sh artifacts: when: always expire_in: 7d reports: junit: - ./build/test-results/test/*.xml paths: - ./build/reports/tests/* deploy_plugin: image: adoptopenjdk:11-jdk stage: deploy script: - ./scripts/bash/deploy_plugin.sh dependencies: - test_plugin #Only on master branch only: - main
内容的提问来源于stack exchange,提问作者Luis Muñiz
相关产品推荐
相关产品推荐

