Gitlab-CI,按计划运行,但仅在有更改的情况下 [英] Gitlab-CI, run on schedule but only if there are changes

查看:62
本文介绍了Gitlab-CI,按计划运行,但仅在有更改的情况下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想每天部署一次项目,但前提是必须进行更改.我每个月都有一个特定的小时可以部署,并且我对使用计划的管道触发和部署感到很满意.

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?

推荐答案

这类似于具有4年历史的功能请求

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 with only or except 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 and package-lock.json because I can run npm install only if there is changes.

  only:
    changes:
      - package.json
      - package-lock.json

警告,如 Matthijs Bierman 所述.Questions/63525941/gitlab-ci按计划运行,但仅在有变化的情况下/63565982?noredirect = 1#comment113608523_63565982>评论,并以

Warning, as noted by Matthijs Bierman in the comments, and as documented here:

请注意,当:已预定

这篇关于Gitlab-CI,按计划运行,但仅在有更改的情况下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆