当GitLab Runner尝试获取项目时,权限被拒绝

时间:2020-03-06 09:06:04

标签: git gitlab gitlab-ci

我正在尝试使用GitLab CI建立管道,但是我的Runner是外壳执行程序运行程序。我遇到了一些问题。

基本上,测试会生成很多文件。为了保持文件系统的清洁,我在每个管道的开头运行此作业,该作业只会擦除最后一个管道中剩余的所有文件的整个项目构建目录:

cleanup_job:
    stage: cleanup_phase
    variables:
        GIT_STRATEGY: none
    script:
        - sudo rm -rf *
        - sudo rm -rf .git
        - cd ~
        - sudo chown -R gitlab-runner builds/

然后第二项工作是使用GIT STRATEGY: fetch导入项目并使用Composer安装它:

install_framework:
    stage: setup
    variables:
        GIT_STRATEGY: fetch
    script:
         - ls -la
         - eval $(ssh-agent)
         - ssh-add
         - composer install
         - cd ~
         - sudo chown -R gitlab-runner builds/

我的问题是,除非在运行管道之前删除 / home / gitlab-runner / builds 文件夹,否则install_framework作业在初始获取期间将失败:

Running with gitlab-runner 12.7.1 (003fe500)
   on Local Runner vYk7fjSG
Using Shell executor...
Running on localhost.localdomain...
Fetching changes...
 /home/gitlab-runner/builds/vYk7fjSG/0/ent/qa/test_project/.git: Permission denied
 ERROR: Job failed: exit status 1

这非常令人沮丧,我不知道为什么会发生。 .git甚至在我刚刚删除它时就不存在。

1 个答案:

答案 0 :(得分:0)

使用clone作为我的GIT_STRATEGY修复了