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

时间:2018-02-22 08:22:55

标签: gitlab gitlab-ci gitlab-ci-runner

我正在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

我的setup阶段成功运行(作业被移动到构建阶段),但是存在致命错误,并且从未执行缓存。
如果我们详细查看它失败的原因,路径真的很奇怪:

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

我也尝试没有cache:key,但错误或多或少相同:

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

1 个答案:

答案 0 :(得分:0)

您需要在sed 's#\(.*\) .*#s/^\1$/&/#' file1 | sed -f - file2 用户主目录下创建目录,并拥有整个缓存目录的所有权。

在您的特定情况下,运行以下命令

gitlab-runner