Gitlab-CI,按计划运行,但前提是有变化 [英] Gitlab-CI, run on schedule but only if there are changes

查看:48
本文介绍了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 年前的功能请求 gitlab-org/gitlab-foss 问题 19813

This is similar to a 4 years old feature request gitlab-org/gitlab-foss issue 19813

我有一个相当大的项目,我正在使用带有 Pages 的 GitLab CI 来部署它,但是,当我在 repo 中更改任何内容时,它会运行 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/except:changes

The recent (July 2020) conclusion is to use only:changes/except:changes

changes 关键字与 onlyexcept 一起使用可以定义是否应根据 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.jsonpackage-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评论,以及 记录在这里:

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

请注意,only: changes notwhen:scheduled

这篇关于Gitlab-CI,按计划运行,但前提是有变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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