How to use GitLab CI only:changes with only:refs?

2019-08-27 22:33发布

My .gitlab-ci.yml configuration has a job like:

Lint dummy:
  stage: prepare
  tags: [my-tag]
  only:
    refs: [merge_requests]
    changes: [Thorfile]
  script: "/bin/true"

The only difference from the real job is the tags. Everything else is exactly the same.

Yes, when creating a merge request where Thorfile has not been changed, the "Lint dummy" job is still created.

From the documentation as of 2019.03.14 (https://docs.gitlab.com/ee/ci/yaml/README.html#using-changes-with-merge_requests)

With pipelines for merge requests, make it possible to define if a job should be created base on files modified in a merge request.

For example:

docker build service one:
  script: docker build -t my-service-one-image:$CI_COMMIT_REF_SLUG .
  only:
    refs:
      - merge_requests
    changes:
      - Dockerfile

I am using GitLab 11.7.5.

1条回答
ら.Afraid
2楼-- · 2019-08-27 23:03

Support for only:changes will be available in the next release:

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24490

Edit:

released now (version 11.9). here is the documentation:

https://docs.gitlab.com/ee/ci/yaml/#using-changes-with-merge_requests

查看更多
登录 后发表回答