Gitlab-Bot对接企业微信机器人
将Gitlab的push、tag push、merge request和pipeline推送到企业微信的机器人。
项目地址:https://github.com/goodideal/gitlab-bot
环境准备
172.16.20.30
root / Pass9527
#已安装dokcer、docker-compose、git
部署步骤
安装基本环境和工具
[root@gitlab-bot ~]# yum install vim net-tools docker git -y
配置https代理和git代理
[root@gitlab-bot ~]# git config --global https.proxy https://172.16.2.14:7777
[root@gitlab-bot gitlab-bot]# export https_proxy=https://172.16.2.16:3128
clone项目
[root@gitlab-bot ~]# git clone https://github.com/goodideal/gitlab-bot.git
正克隆到 'gitlab-bot'...
remote: Enumerating objects: 56, done.
remote: Counting objects: 100% (56/56), done.
remote: Compressing objects: 100% (37/37), done.
remote: Total 56 (delta 11), reused 51 (delta 7), pack-reused 0
Unpacking objects: 100% (56/56), done.
安装docker-compose
[root@gitlab-bot gitlab-bot]# curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 651 100 651 0 0 568 0 0:00:01 0:00:01 --:--:-- 568
100 15.4M 100 15.4M 0 0 259k 0 0:01:00 0:01:00 --:--:-- 632k
[root@gitlab-bot gitlab-bot]# chmod +x /usr/local/bin/docker-compose
[root@gitlab-bot gitlab-bot]# ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
[root@gitlab-bot gitlab-bot]# docker-compose -version
docker-compose version 1.24.1, build 4667896b
编辑gitlab-bot配置文件,并使用docker-compose部署
修改docker-compose.yml文件中的WEBHOOK_URL环境变量,添加企业微信机器人的webhook地址。
[root@gitlab-bot ~]# cd gitlab-bot/
[root@gitlab-bot gitlab-bot]# systemctl start docker
[root@gitlab-bot gitlab-bot]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@gitlab-bot gitlab-bot]# docker-compose up -d
~~~
[root@gitlab-bot gitlab-bot]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8b1ade043716 gitlab-bot_bot "docker-entrypoint..." About a minute ago Up About a minute 0.0.0.0:7001->7001/tcp gitlab-bot_bot_1