3

如果我的唯一更改部分与文件commit/merge request相关,我需要跳过管道中的 GitLab CI 作业。*.md, eslintrc.json or jsconfig.json

例子:

  • 如果这些文件已更改,但 *.js 等其他文件也已更改:作业应该运行。
  • 如果这些文件根本没有更改,但其他 *.js 文件已更改:作业应该运行。
  • 如果 README.md 和 eslintrc.json 发生了变化,并且没有其他任何变化:作业不应该运行

我试图做到这一点,但到目前为止我还没有发现except:changes也没有用。rules:when:never我该怎么做?

4

2 回答 2

0

如果我理解正确,您需要except:changes在 CI 文件中有约定。

看看这个例子。如果 *.md、eslintrc.json 和 jsconfig.json 发生更改,则作业会在任何条件下运行。在这种情况下,管道将不会运行。检查以下示例的异常更改阶段。

另一方面,您可以设置在任何js文件发生更改的情况下运行管道。检查以下示例的 * only-changes* 阶段。

stages:
  - except-changes
  - only-changes

ignore-file-changes:
  stage: except-changes
  script:
    - echo "Skip running the pipeline if *.md, eslintrc.json and jsconfig.json has any kind of change."
  except: 
    changes:
      - "**/*.md"
      - eslintrc.json
      - jsconfig.json
      - README.md
  
pass-the-pipeline:
  stage: only-changes
  script:
    - echo "Run only *.js and Dockerfile files has any kind of change."
  only:
    changes:
      - Dockerfile
      - "**/*.js"

于 2021-12-07T22:33:59.250 回答
0

这个问题有一个类似的问题,包括在评论中提出解决方法的建议。(只有降价更改时有没有办法跳过管道?rules:when:neverorexcept:changes功能目前似乎不支持这一点。他们用 GitLab 开了一张票。

于 2022-02-28T13:59:05.753 回答