简体   繁体   English

SAST 作业失败 + GitLab + Spring 启动 + Maven

[英]SAST job fails + GitLab + Spring boot + Maven

I have a multi-module maven Spring Boot project.我有一个多模块 maven Spring 引导项目。 During the Test pipeline stage, I get the below error.在测试管道阶段,出现以下错误。

 The specified user settings file does not exist: /builds/teams/systems/service/app/modals/.m2/ci_settings.xml

The project app has two modules -> service & modals .该项目app有两个模块 -> service & modals The project root has a.m2 folder within which lies the settings.xml file.项目根目录有一个 .m2 文件夹,其中包含 settings.xml 文件。

I have included the common.gitlab-ci.yml which has the SAST template included.我包含了包含 SAST 模板的common.gitlab-ci.yml The issue is that the spotbug-sast job fails and complains that the service module does not have a.m2/settings.xml file.问题是spotbug-sast作业失败并抱怨service模块没有 a.m2/settings.xml 文件。 To test, I tried creating a file at the same path in service module which worked but failed to build modals .为了测试,我尝试在service模块中的相同路径创建一个文件,该文件有效但未能构建modals The same may also work with modals as well if I create the settings.xml file within modals .如果我在modals modals

Here is the (partial) gitlab-ci yaml:这是(部分)gitlab-ci yaml:

 variables:
   MAVEN_CLI_OPTS: -s .m2/ci_settings.xml --batch-mode
   MAVEN_OPTS: -Dmaven.repo.local=.m2/repository
 
 
 stages:
   - compile
   - test
    
 include:
   - project: '/gitlab/'
     ref: master
     file: '/security/common.gitlab-ci.yml'
   
 compile:
   image: maven:3.6.3-jdk-8-slim
   stage: compile
   script:
     - mvn $MAVEN_CLI_OPTS clean compile $MAVEN_OPTS
   only:
     - merge_requests
     - web
     
 test:
   image: maven:3.6.3-jdk-8-slim
   stage: test
   script:
     - mvn $MAVEN_CLI_OPTS verify $MAVEN_OPTS
   only:
     - merge_requests
     - web

Everything worked perfectly before adding this SAST template.在添加此 SAST 模板之前,一切都运行良好。 I am not sure if it is correct to create the settings.xml file inside all the modules.我不确定在所有模块中创建settings.xml文件是否正确。

How can I get rid of this error?我怎样才能摆脱这个错误? Please help to understand how this works.请帮助理解这是如何工作的。

I had the same problem and could solve it by making the Maven settings path absolute.我遇到了同样的问题,可以通过将 Maven 设置路径设置为绝对路径来解决。 In your example this would be:在您的示例中,这将是:

variables:
  MAVEN_CLI_OPTS: -s $CI_PROJECT_DIR/.m2/ci_settings.xml --batch-mode

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM