【发布时间】:2022-04-23 01:59:09
【问题描述】:
您好,我正在使用以下 gitlab yml 文件来设置我的管道。该项目是一个 Maven Java 项目。但我无法成功运行所有步骤。这是gitlab yml:
image: maven:3.5-jdk-8
variables:
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
include:
- template: Security/SAST.gitlab-ci.yml
cache:
paths:
- .m2/settings.xml
# Define stages
# Stages group various steps into one block,
# if any step fails, the entire stage fails
stages:
- validate
- compile
- SonarQube
- test
validate:
stage: validate
script:
- mvn validate
compile:
stage: compile
script:
- mvn $MAVEN_CLI_OPTS compile
sonarqube-check:
image: maven:3.6.3-jdk-11
stage: SonarQube
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
script:
- mvn sonar:sonar -Dsonar.projectKey=key -Dsonar.host.url=url -Dsonar.login=id
allow_failure: true
spotbugs-sast:
variables:
COMPILE: "false"
SECURE_LOG_LEVEL: "debug"
artifacts:
reports:
sast: gl-sast-report.json
#spotbugs-sast:
# variables:
# SECURE_LOG_LEVEL: "debug"
#FAIL_NEVER: 1
test:
image: maven:3.5-jdk-8
stage: test
script:
- mkdir -p /opt/path/conf/project/
- echo ${CI_PROJECT_DIR}
- cp "${CI_PROJECT_DIR}/project.properties" "/opt/path/conf/project/"
- mvn $MAVEN_CLI_OPTS test -B
但我分阶段遇到错误:sonarqube、spotbug-sast 和测试。
- 在 sonarqube 中,显示错误为:无法通过 jar 文件列表解析项目依赖项:
无法解析以下工件:webpay:webpay-client:jar:4.0.4, mpienhanced:mpienhanced:jar:1.0.0, webpay:webpay-mpi:jar:4.3.9, webpay:matrix-mpi :jar:1.27.4, webpay:vbv-matrix:jar:1.12.1, webpay:xercesImpl:jar:2.12.0, webpay:xss4j:jar:0.0.1, webpay:xmlParserAPIs:jar:2.11.0, webpay :webpay-mpi-util:jar:4.2.2
-
在 spotbugs-sast 中,我收到以下错误: [INFO] [查找安全漏洞] [2022-01-13T10:41:39Z] ▶ 找到 1 个可分析项目。 [FATA] [查找安全漏洞] [2022-01-13T10:41:39Z] ▶ lstat /root/.m2/repository: 没有这样的文件或目录
-
在测试阶段,它无法从配置文件中提到的路径获取属性文件。我试图将属性文件放在所有地方并指定路径,但没有成功。
有人可以帮助解决我的问题吗?提前致谢。 如果需要任何其他信息,请告诉我。
【问题讨论】:
-
您是否使用不同的图像运行每个阶段?
-
不,我也尝试过使用全局图像来运行每个阶段,但不是运气
-
好的,您要先尝试
SonarQube阶段吗?你能试试this的方法吗? -
尝试了给出的答案,但仍然遇到相同的错误。未能执行目标。
-
任何帮助将不胜感激。提前致谢。
标签: java maven gitlab continuous-integration yaml