我对gitlab的持续集成有困难。在本地主机中,即使是单元测试yarn start
,它也能正常工作。
我的.yarnrc.yml
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-2.4.2.cjs
请问如何使用gitlab-ci.yml
在gitlab中安装特定版本的纱线?
我尝试过这种不同的配置,但都失败了。
my gitlab-ci.yml
...
unit-tests:
stage: test
image: node:15.2.1-alpine3.11
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .yarn/
script:
- yarn set version 2.4.2
/* tested also with
yarn set version https://cdn.jsdelivr.net/npm/2.4.2@1.0.0/
yarn set version 2.4.2.cjs
yarn set version https://cdn.jsdelivr.net/npm/2.4.2
*/
- yarn install
- yarn build
- yarn test
错误
00:01
Using docker image sha256:7ddc154413f500a1ec545a38fe661bf0fd138e061495e5786ef017352b52c52d for node:15.2.1-alpine3.11 with digest node@sha256:7614f96f47ede63333a7ddbd31c71207956eb39b641e724f81c198c067bacf41 ...
$ yarn set version 2.4.2.cjs
Resolving 2.4.2.cjs to a url...
error An unexpected error occurred: "Release not found: 2.4.2.cjs".
发布于 2021-08-10 06:48:53
这是一个解决方案:单独使用yarn set version 2.4.2
是行不通的
.gitlab-ci.yml
stages:
- test
- release
unit-tests:
stage: test
image: node:15.2.1-alpine3.11
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .yarn/
script:
- yarn set version berry <--- get last version
- yarn set version 2.4.2 <--- then downgrade to a specific version
- yarn install
- yarn build
- yarn test
...
Dockerfile (用于在CI中构建)
...
ENV NODE_ENV production
RUN yarn set version berry
RUN yarn set version 2.4.2
RUN yarn install
...
https://stackoverflow.com/questions/68638893
复制相似问题