![](/img/trans.png)
[英]gitlab job is running even if there is no changes in the schedule pipeline
[英]Run a pre job before GitLab pipeline
每次触发新管道时,我都想运行一项作业。 这是一种准备工作,应始终在.gitlab-ci.yml
中定义的所有其他工作之前执行
例如
stages:
- build
- test
my-prep-job:
stage: .pre
script:
# this is the job I want to run every time a pipeline gets triggered before other jobs
# also it will have an artifact that I want to use in rest of the job
...
artifacts:
...
Build:
stage: build
...
Test:
stage: test
....
请让我知道这是否可能或是否有其他方法。
提前致谢...
编辑
我确实尝试在stage下添加.pre 。 事情是我必须重写规则并将其添加到我的准备工作阶段。
stages:
- .pre # I did add it over here
- build
- test
此外,我还必须将规则添加到此阶段,以便它不会仅在正常提交/推送时自行运行。
是否有可能扩展 GitLab 管道的“.pre”阶段?
您可以使用!reference
标签来包含某些关键字部分。 例如:
.pre
script:
- echo from pre
example:
stage: test
script:
- !reference [.pre, script]
- ...
将.pre
的script
部分包含到示例作业中。
您可以将!reference
用于大多数工作关键字,例如artifacts
或rules
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.