Gitlab-CI,按计划运行,但仅在有更改的情况下 [英] Gitlab-CI, run on schedule but only if there are changes
问题描述
我想每天部署一次项目,但前提是必须进行更改.我每个月都有一个特定的小时可以部署,并且我对使用计划的管道触发和部署感到很满意.
I'd like to deploy my project once per day, but only if there have been changes. There is a specific hour each that I am able to deploy during and I am comfortable with using a scheduled pipeline to trigger and deploy.
但是,并非总是有需要部署的更改.理想情况下,如果自上次部署以来对代码库没有进行任何更改,则管道不会在这一天运行.
However, there aren't always changes that require deployment. Ideally, if there have been no changes to the code base since the last deployment, the pipeline wouldn't run that day.
有没有办法实现这种行为?
Is there any way to achieve this behaviour?
推荐答案
This is similar to a 4 years old feature request gitlab-org/gitlab-foss
issue 19813
GitLab CI仅在特定文件夹已更改时执行
我有一个很大的项目,并且我正在使用带有Pages的GitLab CI进行部署,但是,当我在仓库中更改任何内容时,它将运行CI.
GitLab CI only execute when a certain folder has changed
I have quite a large project, and I'm using GitLab CI with Pages to deploy it, however, when I change anything in the repo, it runs CI.
我不希望发生这种情况,我希望它仅在 src
文件夹更改时才能运行.
这可能吗?
I don't want this to happen, I want it to run only if the src
folder changes.
Is this possible?
最近(2020年7月)的结论是使用 only:changes
/除外:更改
The recent (July 2020) conclusion is to use only:changes
/except:changes
仅将
changes
关键字与或
except
结合使用,可以定义是否应基于Git修改的文件来创建作业.推送事件.
Using the
changes
keyword withonly
orexcept
makes it possible to define if a job should be created based on files modified by a Git push event.
示例:
我想要此功能,尤其是对于
package.json
和package-lock.json
,因为只有在有更改的情况下,我才能运行npm install
I wanted this feature especially for
package.json
andpackage-lock.json
because I can runnpm install
only if there is changes.
仅
only:
changes:
- package.json
- package-lock.json
警告,如
Warning, as noted by Matthijs Bierman in the comments, and as documented here:
请注意,当:已预定
这篇关于Gitlab-CI,按计划运行,但仅在有更改的情况下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!