如何让 gitlab-runner 从指定文件读取而不是 .gitlab-ci.yml?

How to make gitlab-runner read from a specified file instead .gitlab-ci.yml?

我在本地使用 gitlab-runner,在包含 .gitlab-ci.yml 的存储库的根目录中使用 sudo gitlab-runner exec docker [job name]。是否可以从 .gitlab-ci.yml 之外的另一个文件读取 运行ner 配置?

我知道我可以在同一个 .gitlab-ci.yml 中管理不同作业的不同配置。

我知道 gitlab-runner exec 已被弃用,计划仅替换它,但尚未实现(有关详细信息,请参阅 https://gitlab.com/gitlab-org/gitlab-runner/issues/2797),因此非常感谢有关也是继任者。

我使用名为 a 的 YAML 创建了 https://gitlab.com/krichter/gitlab-runner-local-different-name,其中包含一个名为 main 的 "Hello world"-echo,我想 运行 作为示例,无需将 a 重命名为 .gitlab-ci.yml.

运行 它与 sudo gitlab-runner exec docker main --env CI_CONFIG_PATH=a 由于

而失败
WARNING: Since GitLab Runner 10.0 this command is marked as DEPRECATED and will be removed in one of upcoming releases 
fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
FATAL: open .gitlab-ci.yml: no such file or directory

你可以gitlab-runner exec docker job --env CI_CONFIG_PATH=[pathtoyml]

参见: https://gitlab.com/gitlab-org/gitlab-runner/issues/312

另请参阅: https://docs.gitlab.com/ce/ci/variables/README.html

真的不能:.gitlab-ci.yml 被硬编码到 gitlab-runner exec 代码中。我创建了 issue about this problem。如果它仍然适合您,请点赞。