【问题标题】:can't fetch another git repo using .gitmodules in gitlab-ci无法在 gitlab-ci 中使用 .gitmodules 获取另一个 git repo
【发布时间】:2020-02-09 12:17:20
【问题描述】:

我尝试使用 gitlab-ci 构建管道以生成一组微服务 jar,并从独立服务开始作为试用版,但 .gitmodules 文件无法正常工作,我将其配置为 gitlab-doc 解释

这是我的.gitmodules 文件

[submodule "logging-service"]
    path = logging-service
    branch = develop
    url = ../logging-service

这是我的.gitlab-ci.yml 文件

stages:
  - maven_build
  - test_coverage
  - sonar_qube
  - deploy_cf_critical_services_dev
  - deploy_cf_rest_of_services_dev
  - postman_tests

variables:
  GIT_SUBMODULE_STRATEGY: recursive
  SONAR_URL: http://localhost:9000
  SONAR_USERNAME: admin
  SONAR_PASSWORD: admin

sonar_qube_phase_logging-service:
  image: sonarqube:latest
  stage: sonar_qube
  script: 
    - mvn -f sonar:sonar logging-service/pom.xml -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_USERNAME -Dsonar.password=$SONAR_PASSWORD

test_coverage_phase_logging-service:
  image: dockerproxy-iva.si.francetelecom.fr/maven:3.3.9-jdk-8
  stage: test_coverage
  script: 
    - mvn clean verify -f ../logging-service/pom.xml

maven_build_phase_logging-service:
  image: dockerproxy-iva.si.francetelecom.fr/maven:3.3.9-jdk-8
  stage: maven_build
  script: 
    - mvn install -f logging-service/pom.xml -Dmaven.test.skip=true 
  artifacts:
    name: logging-service #jar name 
    paths:
      - logging-service/target
    expire_in: 1 day

并且从 maven 生成的错误在路径中找不到 pom.xml 错误路径

/builds/ole_bothub/bothub-deployment-dev/logging-service/pom.xml

并且路径应该如下所示

/builds/ole_bothub/logging-service/pom.xml

这里是 maven_build_phase_logging-service 作业的日志


 Updating/initializing submodules recursively...

$ mvn install -f logging-service/pom.xml -Dmaven.test.skip=true
[INFO] Scanning for projects...
 [ERROR] [ERROR] Some problems were encountered while processing the POMs:
 [FATAL] Non-readable POM /builds/ole_bothub/bothub-deployment-dev/logging-service/pom.xml: /builds/ole_bothub/bothub-deployment-dev/logging-service/pom.xml (No such file or directory) @ 
  @ 
 [ERROR] The build could not read 1 project -> [Help 1]
 [ERROR]   
 [ERROR]   The project  (/builds/ole_bothub/bothub-deployment-dev/logging-service/pom.xml) has 1 error
 [ERROR]     Non-readable POM /builds/ole_bothub/bothub-deployment-dev/logging-service/pom.xml: /builds/ole_bothub/bothub-deployment-dev/logging-service/pom.xml (No such file or directory)
 [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/ProjectBuildingException

【问题讨论】:

    标签: git gitlab gitlab-ci


    【解决方案1】:

    我通过删除 .gitmodules 文件并通过以下步骤使用git-CLI 创建另一个来解决它

    • 将单独的 ci-repo 克隆到我的本地计算机
      git clone <repo_ci_URL>
    • 开始使用 git-cli 添加子模块
      git submodule add <referenced_repo>
    • 提交更改到我的 ci-repo
      git commit -m "mys message"
    • 对我想要添加到我的 ci 管道的所有 git 存储库重复上一步
    • 最终将更改推送到您的 ci-repo

    并开始我的管道,一切对我来说都很顺利。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-07
      • 2021-03-21
      • 1970-01-01
      • 2011-11-01
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多