提问者:小点点

GitLab CI/CD 缓存错误:文件名、目录名称或卷标语法不正确


我正在Windows Server 2012上安装并运行GitLab-Runner。我正在尝试缓存node_modules文件夹。
我遵循了互联网上的许多示例并编写了以下yml:

cache:
  key: "%CI_PROJECT_NAME%"       #Defines when to cache.
  untracked: true
  paths:
    - node_modules/

variables:
    SOLUTION: $CI_PROJECT_DIR\App.Web.sln

stages:
    - setup
    - build

setup:                                                                                      #From: https://gitlab.com/gitlab-org/gitlab-ce/issues/12963
    stage: setup
    script:
        - npm install                                                                       #Install all packages

build_backend:
    stage: build
    script:
        - echo "Building backend branch '%CI_COMMIT_REF_NAME%' for '%SOLUTION%'."
        - dotnet restore "%SOLUTION%"
        - dotnet msbuild /p:Configuration=Release "%SOLUTION%"
    except:
        - tags

build_frontend:
    stage: build
    script:
        - echo "Building frontend branch '%CI_COMMIT_REF_NAME%' for '%SOLUTION%'."
        - npm run build:vendor && npm run build:webpack
    except:
        - tags

我的< code>setup阶段成功运行(作业移至构建阶段),但存在致命错误,并且从不执行缓存。< br >如果我们仔细看看失败的原因,path确实很奇怪:

FATAL: open ..\..\..\..\..\cache\web\app\app:1\cache.zip: The filename, directory name, or volume label syntax is incorrect.
                            |     |   |    |
                           (1)   (2) (3)  (4)
                                          ??? 
(1) This is GitLab-Runner root dir
(2) GitLab group for project
(3) Project name
(4) I think this cause problems, because aap:1 is invalid dir name.

完整日志:

Running with gitlab-runner 10.4.0 (857480b6)
  on Dexter (7cab42e4)
Using Shell executor...
Running on DEXTER...
Fetching changes...
HEAD is now at b0344f2 Fix
Checking out 692e0373 as 51-move-ci-cd-to-docker...
Skipping Git submodules setup
Checking cache for %CI_PROJECT_NAME%:1...
FATAL: open ..\..\..\..\..\cache\web\app\app:1\cache.zip: The filename, directory name, or volume label syntax is incorrect. 
Successfully extracted cache
$ npm install
....
....
added 1489 packages in 245.681s
Creating cache %CI_PROJECT_NAME%:1...
node_modules/: found 47345 matching files          
WARNING: GetFileAttributesEx ..\..\..\..\..\cache\web\app\app:1\cache.zip: The filename, directory name, or volume label syntax is incorrect. 
FATAL: open ..\..\..\..\..\cache\web\app\:1\archive_428238003: The filename, directory name, or volume label syntax is incorrect. 
Created cache
Job succeeded

我也在没有< code>cache:key的情况下进行了尝试,但错误大致相同:

FATAL: open ..\..\..\..\..\cache\web\app\default:1\cache.zip: The filename, directory name, or volume label syntax is incorrect. 

共1个答案

匿名用户

您需要在< code>gitlab-runner用户主目录下创建目录,并授予整个缓存目录的所有权。

在特定情况下运行以下命令

mkdir -p /home/gitlab-runner/cache/web/app/app/

sudo chown -R gitlab-runner:gitlab-runner /home/gitlab-runner/cache/