每次触发新管道时,我都要运行一个作业。这是一种准备工作,应该在.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
....请告诉我这是可能的还是有别的办法。
提前谢谢..。
编辑
我确实尝试过将.pre添加到stages中。问题是,我必须重写规则,并将其添加到,我的准备工作阶段。
stages:
- .pre # I did add it over here
- build
- test此外,我还必须将规则添加到这个阶段,这样它就不会在正常的提交/推送上单独运行。
是否有可能延长".pre“阶段的GitLab管道?
发布于 2022-09-18 20:26:01
您可以使用!reference标记来包含某些关键字部分。例如:
.pre
script:
- echo from pre
example:
stage: test
script:
- !reference [.pre, script]
- ...将.pre的.pre部分包含到示例作业中。
您可以将!reference用于大多数工作关键字,如artifacts或rules。
https://stackoverflow.com/questions/73764720
复制相似问题