2017-04-25 45 views
0

我有用於構建和運行測試的gitlab-ci腳本。但是,在構建過程中創建的目錄被刪除。 我的腳本:緩存文件不存儲在GitLab的所有階段CI

stages: 
    - build 
    - test 

server: 
    stage: build 
    script: 
    - cd Server/NodeJS 
    - npm install 
    - npm install zmq 
    cache: 
    key: "$CI_BUILD_NAME" 
    untracked: true 
    paths: 
    - Server/NodeJS/node_modules/ 

client: 
    stage: build 
    script: 
    - cd Client/web 
    - npm install 
    - npm run build-demo 
    - npm run build-main 
    cache: 
    key: "$CI_BUILD_NAME" 
    untracked: true 
    paths: 
    - Client/web/build-main/ 

functional_tests: 
    stage: test 
    script: 
    - cd Server/NodeJS 
    - ls node_modules/ 
    - ls ../../Client/web/ 
    ... 

ls不打印緩存目錄。我究竟做錯了什麼?

+1

您應該使用工件而不是緩存作爲用例。 –

回答

2

由於您還沒有定義全局緩存,所以在functional_tests作業中既沒有緩存,也不知道有沒有。

你需要做這樣的事情:

functional_tests: 
    stage: test 
    script: 
    - cd Server/NodeJS 
    - ls node_modules/ 
    - ls ../../Client/web/ 
    cache: 
    key: "$CI_BUILD_NAME" 
    untracked: true 
    paths: 
    - Client/web/build-main/ 
    - Server/NodeJS/node_modules/ 

而且,請注意,緩存,提供了最好的努力的基礎上,所以不要指望高速緩存將始終存在。

因此,您不能假設總會有緩存,您需要編寫腳本,因爲沒有。