简体   繁体   中英

can't fetch another git repo using .gitmodules in gitlab-ci

I try build pipeline using gitlab-ci to generate set of micro-services jars and start with independent service as trial but .gitmodules file don't work correctly i configure it as gitlab-doc explained

here is my .gitmodules file

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

and here is my .gitlab-ci.yml file

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

and error generated from maven can't find pom.xml in path error path

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

and the path should be like the following

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

and here is log of maven_build_phase_logging-service job


 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

I solve it by delete .gitmodules file and create another one using git-CLI by the following step

  • clone separate ci-repo to my local machine
    git clone <repo_ci_URL>
  • start to add submodules using git-cli
    git submodule add <referenced_repo>
  • commit changes to my ci-repo
    git commit -m "mys message"
  • repeat previous step to all git repos I want to add to my ci pipeline
  • finally push changes to your ci-repo

and start my pipeline and everything work well to me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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