Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gitlab CI未下载正确的子模块文件_Git_Gitlab_Gitlab Ci_Git Submodules - Fatal编程技术网

Gitlab CI未下载正确的子模块文件

Gitlab CI未下载正确的子模块文件,git,gitlab,gitlab-ci,git-submodules,Git,Gitlab,Gitlab Ci,Git Submodules,我试图在我的应用程序中使用一个私有git repo作为子模块。 在本地,我可以克隆我的主repo并正确地拉取所有子模块 我正在使用GitLab.com作为我的主机和运行程序。 在GitLab runner中,GitHub托管的公共repo可以正常运行,但私有GitLab托管的repo不会运行最新代码。 我是主项目以及私有子模块的所有者 我注意到这是在我在处理我的主项目时对我的子模块做了一个修改并将其推到子模块之后开始的 当我尝试在GitLab runner上进行自动构建时,子模块将被拉入,但即使

我试图在我的应用程序中使用一个私有git repo作为子模块。 在本地,我可以克隆我的主repo并正确地拉取所有子模块

我正在使用GitLab.com作为我的主机和运行程序。 在GitLab runner中,GitHub托管的公共repo可以正常运行,但私有GitLab托管的repo不会运行最新代码。 我是主项目以及私有子模块的所有者

我注意到这是在我在处理我的主项目时对我的子模块做了一个修改并将其推到子模块之后开始的

当我尝试在GitLab runner上进行自动构建时,子模块将被拉入,但即使它显示了正确的(当前/最新的)Git Ref SHA1,这些文件还是显示在很久以前的提交中。我已经尝试了许多迭代的方法来获取私有回购协议,并且我已经对我的子模块进行了无关紧要的更改。即使如此,我仍然无法提取最新版本的子模块代码

我已经尝试使用内置来拉取子模块,并且设置了before_脚本来尝试手动拉取

我还确保更新我的本地子模块,并将更改提交到我的主repo

下面是使用GitLab runner变量

  variables:
    GIT_SUBMODULE_STRATEGY: recursive
这是一个在脚本之前的示例,我尝试过使用和不使用GIT_子模块_策略:none 我已经尝试过许多这种方法的变体,删除和添加行以获取最新的代码

    - git submodule sync --recursive
    - git submodule update --force --recursive --remote
    - git submodule foreach git pull
    - git submodule status
    - git submodule foreach git log -1
预期: GitLab runner应该提取子模块分支上的最新提交

实际:
GitLab拉取子模块,但在某个提交后的代码更改不会显示,即使所显示的提交是当前的。

在花了上一周的时间试图解决这个问题后,我今天找到了一个解决方案。 我发现这有助于我最终解决问题

这是我的gitlab-ci.yml

stages:
  - deployGAE

deploy_production:
  image: google/cloud-sdk:alpine
  stage: deployGAE
#  variables:
#    GIT_SUBMODULE_STRATEGY: recursive
  environment:
    name: Production
  only:
    - master
  before_script:
    - git submodule update --init --remote --merge
    - git submodule status
    - git submodule foreach git log -1
  script:
    # Set GCloud service account key
    - echo $SERVICE_ACCOUNT > /tmp/$CI_PIPELINE_ID.json
    # Authenticate to GCloud API
    - gcloud auth activate-service-account --key-file /tmp/$CI_PIPELINE_ID.json
    # Globally set the GCLoud project for future commands
    - gcloud config set project $PROJECT_ID
    # Deploy the app to GCloud Build for deployment on App Engine
    - gcloud --quiet app deploy app.yaml #--verbosity=info
    # Remove versions that are no longer serving traffic
    - gcloud --quiet app versions delete $(gcloud app versions list --sort-by '~version' --format 'value(version.id)' --filter="TRAFFIC_SPLIT:0.00")
  after_script:
    # Remove the GCloud service account key
    - rm /tmp/$CI_PIPELINE_ID.json