gitlab ci不正确合并

发布于 2025-02-05 02:17:29 字数 1613 浏览 2 评论 0原文

大家好,假设这是我的gitlab ci

.gitlab-ci.yml

stages:
  - install
  - build
  


before_script:
  - nvm install 14.17
  - nvm use 14.17
  - npm install -g [email protected] --registry=$NPM_REGISTRY
  - npm install -g semantic-release
  - git fetch --all

include: '/ci/install_stage.yml'
include: '/ci/build_stage.yml'

/ci/install_stage.yml

install:
  stage: install
  tags:
    - fe
    - xdev
  artifacts:
    expire_in: 1 day
    paths:
      - node_modules/
  only:
    changes:
      - .gitlab-ci.yml
      - package.json
      - packages/**/*
  script:
    - yarn install
  cache:
    key: '$CI_PROJECT_PATH-package'
    paths:
      - $CI_PROJECT_DIR/node_modules/

/ci/build_stage.yml

build:
  stage: build
  tags:
    - fe
    - xdev
  artifacts:
    expire_in: 1 day
    paths:
      - $CI_PROJECT_DIR/dist
  only:
    changes:
      - .gitlab-ci.yml
      - package.json
      - packages/**/*
  script:
    - yarn build
  dependencies:
    - install
  cache:
    key: '$CI_PROJECT_PATH-CI_COMMIT_REF_SLUG-build'
    paths:
      - $CI_PROJECT_DIR/dist

想要在安装之后仅运行构建,这就是为什么我将dependencies放在build> build> build job中。但是,皮棉给我错误构建作业不确定的依赖性安装

因此在合并之前,Gitlab的皮棉似乎是不小心完成的吗?

无论如何要解决这个问题?谢谢

Hi guys assume this is my gitlab ci

.gitlab-ci.yml

stages:
  - install
  - build
  


before_script:
  - nvm install 14.17
  - nvm use 14.17
  - npm install -g [email protected] --registry=$NPM_REGISTRY
  - npm install -g semantic-release
  - git fetch --all

include: '/ci/install_stage.yml'
include: '/ci/build_stage.yml'

/ci/install_stage.yml

install:
  stage: install
  tags:
    - fe
    - xdev
  artifacts:
    expire_in: 1 day
    paths:
      - node_modules/
  only:
    changes:
      - .gitlab-ci.yml
      - package.json
      - packages/**/*
  script:
    - yarn install
  cache:
    key: '$CI_PROJECT_PATH-package'
    paths:
      - $CI_PROJECT_DIR/node_modules/

/ci/build_stage.yml

build:
  stage: build
  tags:
    - fe
    - xdev
  artifacts:
    expire_in: 1 day
    paths:
      - $CI_PROJECT_DIR/dist
  only:
    changes:
      - .gitlab-ci.yml
      - package.json
      - packages/**/*
  script:
    - yarn build
  dependencies:
    - install
  cache:
    key: '$CI_PROJECT_PATH-CI_COMMIT_REF_SLUG-build'
    paths:
      - $CI_PROJECT_DIR/dist

So basically i want to only run build after install, thats why i put a dependencies in build job. But then the lint give me error build job undefined dependency install

So it seem the lint of Gitlab is done invidually before the merge ?

anyway to fix this ? thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半夏半凉 2025-02-12 02:17:31

对于任何遇到同样问题的人,原因是Gitlab将覆盖包括方法,因此,对于我的情况,它仅包括构建,但不包括安装阶段。

要修复,我更改为阵列类型
包括:['/ci/install_stage.yml','/ci/build_stage.yml']

For anyone having same problem, the reason is gitlab will overwrite include method, therefore, for my case, it only include build but not install stage.

To fix, i changed to an array type
include: ['/ci/install_stage.yml', '/ci/build_stage.yml']

美煞众生 2025-02-12 02:17:30

中includs 文档::

包含文件是:

  • 与.gitlab-ci.yml文件中的那些合并。

  • 始终首先评估,然后与.gitlab-ci.yml文件的内容合并,而不管包括包含的位置如何
    关键字。

因此,您可以更新.gitlab-ci.yml这样的文件,以评估所有内容,因此合并之前,build> build job将知道您的install install作业:

stages:
  - install
  - build

...

include: 
  - '/ci/install_stage.yml'
  - '/ci/build_stage.yml'

From the include documentation :

The include files are:

  • Merged with those in the .gitlab-ci.yml file.

  • Always evaluated first and then merged with the content of the .gitlab-ci.yml file, regardless of the position of the include
    keyword.

So you can update your .gitlab-ci.yml file like this, to evaluate all includes before merging, so the build job will know your install job :

stages:
  - install
  - build

...

include: 
  - '/ci/install_stage.yml'
  - '/ci/build_stage.yml'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文