在设置了全局的 Service Templates 之后,有的 webhook 插件并不能自动应用到每个项目,需要你在相应项目的service templates中去添加一次和启用。例如 SlackService 就无法在每个项目有pipeline或tag时发出通知。

为了自动使能这样的 Service Template 到任一项目,需要登录SSH到gitlab服务器,然后直接操作 pgsql 数据库:

 是这么提供这一hack方案的:

Open a shell on the gitlab server, and execute the following command (note, you must be logged in as a user who has sudo access configured correctly)

sudo -u gitlab-psql /opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql -d gitlabhq_production

Figure out the name of the service template that you want to apply to all of your repositories

select distinct type from services;

Get the properties for the template – verify this is indeed the configuration you’d like to apply to every repository

select properties from services where type = '<Type from previous command>' and template = 't';

Update the properties for all repos to match the properties for the template

Note: The command below also activates the service on all repositories, if you don’t wish to activate simple omit the active='t' bit from the query below.

update services set properties=(select properties from services where type='<Type>' and template='t'), active='t' where type='<Type>' and template='f';

Quit from the postgres client with the \q command and logout of the shell session

这个家伙真的很棒。

美中不足的是,如果新建了repo的话,上面的操作要再来一次。

我现在把公司的gitlab开了全部听,咯咯咯的声音很有意思。

过两天就关了,显然很多了;至少关掉push吧。

但现在我感觉到生活智能化了。

嗯,稍后把ci应用到全部repositories中去。

PS:

 的原文在这里:

https://gitlab.com/gitlab-org/gitlab-ce/issues/3487

Bulk enable new service template to all repos