Gitlab Webhooks, External Services, and API(二)
一. 使用webhooks
webhook 是一个API的概念,并且变得越来越流行。我们能用事件描述的事物越多,webhook的作用范围也就越大。webhook作为 个轻量的事件处理应用,正变得越来越有用。
准确的说webhook是一种web回调或者http的push API, 是向APP或者其它应用提供实时信息的一种方式。webhook在数据产生时立即发送数据,也就是我能实时收到数据。这一种不同于典型的API,需要用了实时性需要足够快的轮询。这无论是对生产还是对消费者都是高效的,唯一的缺点是初始建立困难。
webhook有时也被称为反加API, 因为他提供了API规则,你需要设计要使用的API。WEBHOOK将向你的应用发起http请求,典型的是post请求,应用程序由请求驱动。
1. 搭建要使用的到的服务器RequestBin.(此处我把服务器部署到docker上面的)
(1)刻隆代码
[root@c720120 ~]# git clone git://github.com/Runscope/requestbin.git
Cloning into 'requestbin'...
remote: Counting objects: 636, done.
remote: Total 636 (delta 0), reused 0 (delta 0), pack-reused 636
Receiving objects: 100% (636/636), 652.55 KiB | 397.00 KiB/s, done.
Resolving deltas: 100% (304/304), done.
(2)进入到项目的目录,进行构建和启动容器。
[root@c720120 ~]# cd requestbin/
[root@c720120 requestbin]# docker-compose build
redis uses an image, skipping
Building app
Step 1/8 : FROM python:2.7-alpine
2.7-alpine: Pulling from library/python
ff3a5c916c92: Already exists
5556c6f99b85: Pull complete
93fbc81365bc: Pull complete
8780cd897032: Pull complete
Digest: sha256:cbc1c1c227012034793083306f6f6322e0276ca134c218cc49b131ca59df7699
Status: Downloaded newer image for python:2.7-alpine
---> a448d7554c75
Step 2/8 : RUN apk update && apk upgrade && apk add gcc python python-dev py-pip musl-dev bsd-compat-headers libevent-dev && rm -rf /var/cache/apk/*
---> Running in e57172cecb26
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-214-g519be0a2d1 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-207-gac61833f9b [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
OK: 9054 distinct packages available
Upgrading critical system libraries and apk-tools:
(1/1) Upgrading apk-tools (2.8.2-r0 -> 2.9.1-r2)
Executing busybox-1.27.2-r7.trigger
Continuing the upgrade transaction with new apk-tools:
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
(1/6) Upgrading libressl2.6-libcrypto (2.6.4-r2 -> 2.6.5-r0)
(2/6) Upgrading libressl2.6-libssl (2.6.4-r2 -> 2.6.5-r0)
(3/6) Upgrading busybox (1.27.2-r7 -> 1.27.2-r11)
Executing busybox-1.27.2-r11.post-upgrade
(4/6) Installing libressl2.6-libtls (2.6.5-r0)
(5/6) Installing ssl_client (1.27.2-r11)
(6/6) Upgrading freetype (2.8.1-r2 -> 2.8.1-r3)
Executing busybox-1.27.2-r11.trigger
Executing ca-certificates-20171114-r0.trigger
OK: 32 MiB in 43 packages
(1/21) Installing bsd-compat-headers (0.7.1-r0)
(2/21) Installing binutils-libs (2.30-r1)
(3/21) Installing binutils (2.30-r1)
(4/21) Installing gmp (6.1.2-r1)
(5/21) Installing isl (0.18-r0)
(6/21) Installing libgomp (6.4.0-r5)
(7/21) Installing libatomic (6.4.0-r5)
(8/21) Installing pkgconf (1.3.10-r0)
(9/21) Installing libgcc (6.4.0-r5)
(10/21) Installing mpfr3 (3.1.5-r1)
(11/21) Installing mpc1 (1.0.3-r1)
(12/21) Installing libstdc++ (6.4.0-r5)
(13/21) Installing gcc (6.4.0-r5)
(14/21) Installing libffi (3.2.1-r4)
(15/21) Installing python2 (2.7.14-r2)
(16/21) Installing libevent (2.1.8-r2)
(17/21) Installing libevent-dev (2.1.8-r2)
(18/21) Installing musl-dev (1.1.18-r3)
(19/21) Installing py-setuptools (33.1.1-r1)
(20/21) Installing py2-pip (9.0.1-r1)
(21/21) Installing python2-dev (2.7.14-r2)
Executing busybox-1.27.2-r11.trigger
OK: 185 MiB in 64 packages
Removing intermediate container e57172cecb26
---> bff0b149a3c4
Step 3/8 : ADD requirements.txt /opt/requestbin/
---> 40174275a7cb
Step 4/8 : RUN pip install -r /opt/requestbin/requirements.txt && rm -rf ~/.pip/cache
---> Running in 1ecc38d40702
Collecting gevent==1.0.2 (from -r /opt/requestbin/requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/8a/71/9bb13513d39c513fa71344d57a11affd6ccad775575458f435ff9142daf5/gevent-1.0.2.tar.gz (1.7MB)
Collecting greenlet==0.4.1 (from -r /opt/requestbin/requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/c6/9a/dbb2c9acbde5f2f48e94b9eeacfda511373dfb5534aae8679c06d485419f/greenlet-0.4.1.zip (75kB)
Collecting ProxyTypes==0.9 (from -r /opt/requestbin/requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/72/bd/24f45710e7e6909b2129332363be2c981179ed2eda1166f18bc2baef98a1/ProxyTypes-0.9.zip
Collecting nose==1.3.0 (from -r /opt/requestbin/requirements.txt (line 4))
Downloading https://files.pythonhosted.org/packages/de/f4/b205776cf5cbddbc1e2c3223fa29c0d05f18a9b8afad8cfa23438c217434/nose-1.3.0.tar.gz (404kB)
Requirement already satisfied: wsgiref==0.1.2 in /usr/local/lib/python2.7 (from -r /opt/requestbin/requirements.txt (line 5)) (0.1.2)
Collecting feedparser==5.1.3 (from -r /opt/requestbin/requirements.txt (line 6))
Downloading https://files.pythonhosted.org/packages/eb/d7/143dc058551243c11f76e18117d3818135377049eaadc4edc30a3f34b1d3/feedparser-5.1.3.tar.bz2 (202kB)
Collecting Jinja2==2.7 (from -r /opt/requestbin/requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/33/db/9931c645626f9bf7867cc3c4225e7a8abf7aff37ecddb7e7d5df90a3b6c4/Jinja2-2.7.tar.gz (377kB)
Collecting Werkzeug==0.9.3 (from -r /opt/requestbin/requirements.txt (line 8))
Downloading https://files.pythonhosted.org/packages/8d/3b/79b28e9436f321763bfa47d7784bedb8f0b6b7da92b2979ee5a2a60f3bc6/Werkzeug-0.9.3.tar.gz (1.1MB)
Collecting Flask==0.10.1 (from -r /opt/requestbin/requirements.txt (line 9))
Downloading https://files.pythonhosted.org/packages/db/9c/149ba60c47d107f85fe52564133348458f093dd5e6b57a5b60ab9ac517bb/Flask-0.10.1.tar.gz (544kB)
Collecting Flask-Cors==3.0.2 (from -r /opt/requestbin/requirements.txt (line 10))
Downloading https://files.pythonhosted.org/packages/4f/4f/ea10ca247c21b6512766cf730621697ec2766fb2f712245b2c00983a57b1/Flask_Cors-3.0.2-py2.py3-none-any.whl
Collecting redis==2.7.6 (from -r /opt/requestbin/requirements.txt (line 11))
Downloading https://files.pythonhosted.org/packages/e7/6f/446e6d3cbb6f43d5f73de1be12cd8d033a6f4456ddd8a9dc4cdbd53b389f/redis-2.7.6.tar.gz (76kB)
Collecting msgpack-python==0.1.12 (from -r /opt/requestbin/requirements.txt (line 12))
Downloading https://files.pythonhosted.org/packages/c0/0c/cc5e51b2f82ddee4ceb35e8bceed0545d0c5d2ee632a48a403e46a3495ec/msgpack-python-0.1.12.tar.gz (49kB)
Collecting python-dateutil==2.1 (from -r /opt/requestbin/requirements.txt (line 13))
Downloading https://files.pythonhosted.org/packages/65/52/9c18dac21f174ad31b65e22d24297864a954e6fe65876eba3f5773d2da43/python-dateutil-2.1.tar.gz (152kB)
Collecting gunicorn (from -r /opt/requestbin/requirements.txt (line 14))
Downloading https://files.pythonhosted.org/packages/55/cb/09fe80bddf30be86abfc06ccb1154f97d6c64bb87111de066a5fc9ccb937/gunicorn-19.8.1-py2.py3-none-any.whl (112kB)
Collecting bugsnag (from -r /opt/requestbin/requirements.txt (line 15))
Downloading https://files.pythonhosted.org/packages/64/c5/141fb591b4a460dc169f6ab4a31bd8532bf72c2becf791beb7aa1669676e/bugsnag-3.4.2-py2-none-any.whl (41kB)
Collecting blinker (from -r /opt/requestbin/requirements.txt (line 16))
Downloading https://files.pythonhosted.org/packages/1b/51/e2a9f3b757eb802f61dc1f2b09c8c99f6eb01cf06416c0671253536517b6/blinker-1.4.tar.gz (111kB)
Collecting markupsafe (from Jinja2==2.7->-r /opt/requestbin/requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/MarkupSafe-1.0.tar.gz
Collecting itsdangerous>=0.21 (from Flask==0.10.1->-r /opt/requestbin/requirements.txt (line 9))
Downloading https://files.pythonhosted.org/packages/dc/b4/a60bcdba945c00f6d608d8975131ab3f25b22f2bcfe1dab221165194b2d4/itsdangerous-0.24.tar.gz (46kB)
Collecting Six (from Flask-Cors==3.0.2->-r /opt/requestbin/requirements.txt (line 10))
Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting webob (from bugsnag->-r /opt/requestbin/requirements.txt (line 15))
Downloading https://files.pythonhosted.org/packages/d2/df/9b3b374ea2a82b875a90d1fdcf2c4a652d48f0d1e7c2d1034d636551d4d2/WebOb-1.8.2-py2.py3-none-any.whl (115kB)
Building wheels for collected packages: gevent, greenlet, ProxyTypes, nose, feedparser, Jinja2, Werkzeug, Flask, redis, msgpack-python, python-dateutil, blinker, markupsafe, itsdangerous
Running setup.py bdist_wheel for gevent: started
Running setup.py bdist_wheel for gevent: still running...
Running setup.py bdist_wheel for gevent: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/bf/65/92/5950be5cabfc31ddba3d510e8ebbed6112aba18016472c4aec
Running setup.py bdist_wheel for greenlet: started
Running setup.py bdist_wheel for greenlet: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/9b/00/8b/8064203a9e62f04e7ed1cf5cac6f3ddd695ab74353fd68f8b4
Running setup.py bdist_wheel for ProxyTypes: started
Running setup.py bdist_wheel for ProxyTypes: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/c8/24/65/9797c6999f4d45b25de4d0f280d7ff0b12061eddd750fcc23c
Running setup.py bdist_wheel for nose: started
Running setup.py bdist_wheel for nose: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/9e/23/4a/6d694db85896e8a420efb47a353b7001b2972768f07458f9ea
Running setup.py bdist_wheel for feedparser: started
Running setup.py bdist_wheel for feedparser: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/7b/49/19/8199a0729fd8d58e4f3616d96a7a0e69581b2c046560b52608
Running setup.py bdist_wheel for Jinja2: started
Running setup.py bdist_wheel for Jinja2: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/4d/66/ac/118b76f63c3443b318dc5ee1ba1e39335032305e96cd4dafa0
Running setup.py bdist_wheel for Werkzeug: started
Running setup.py bdist_wheel for Werkzeug: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/e6/fb/6e/4b753478730a5478125485dc99821ff7f4a818ce3cf48abebf
Running setup.py bdist_wheel for Flask: started
Running setup.py bdist_wheel for Flask: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/e1/f2/be/1c4f307a41aad7e632f79c0242a2714ecde24b663da3519665
Running setup.py bdist_wheel for redis: started
Running setup.py bdist_wheel for redis: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/5b/67/92/70dbc6b8e4f01984adde8953dd6319542a7bfee09949d15be9
Running setup.py bdist_wheel for msgpack-python: started
Running setup.py bdist_wheel for msgpack-python: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/94/52/11/ff262175c66991cdec599d3c90bba11ce5a0eab1aac008aa97
Running setup.py bdist_wheel for python-dateutil: started
Running setup.py bdist_wheel for python-dateutil: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/a3/b4/9e/be446328c3728631f286e9cc832b8b00ca99480eefa1a6db4e
Running setup.py bdist_wheel for blinker: started
Running setup.py bdist_wheel for blinker: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/92/a0/00/8690a57883956a301d91cf4ec999cc0b258b01e3f548f86e89
Running setup.py bdist_wheel for markupsafe: started
Running setup.py bdist_wheel for markupsafe: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/33/56/20/ebe49a5c612fffe1c5a632146b16596f9e64676768661e4e46
Running setup.py bdist_wheel for itsdangerous: started
Running setup.py bdist_wheel for itsdangerous: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/2c/4a/61/5599631c1554768c6290b08c02c72d7317910374ca602ff1e5
Successfully built gevent greenlet ProxyTypes nose feedparser Jinja2 Werkzeug Flask redis msgpack-python python-dateutil blinker markupsafe itsdangerous
gevent 1.0.2 has requirement greenlet>=0.4.7, but you'll have greenlet 0.4.1 which is incompatible.
Installing collected packages: greenlet, gevent, ProxyTypes, nose, feedparser, markupsafe, Jinja2, Werkzeug, itsdangerous, Flask, Six, Flask-Cors, redis, msgpack-python, python-dateutil, gunicorn, webob, bugsnag, blinker
Successfully installed Flask-0.10.1 Flask-Cors-3.0.2 Jinja2-2.7 ProxyTypes-0.9 Six-1.11.0 Werkzeug-0.9.3 blinker-1.4 bugsnag-3.4.2 feedparser-5.1.3 gevent-1.0.2 greenlet-0.4.1 gunicorn-19.8.1 itsdangerous-0.24 markupsafe-1.0 msgpack-python-0.1.12 nose-1.3.0 python-dateutil-2.1 redis-2.7.6 webob-1.8.2
Removing intermediate container 1ecc38d40702
---> 0288f2dee287
Step 5/8 : ADD requestbin /opt/requestbin/requestbin/
---> d1996b2ee224
Step 6/8 : EXPOSE 8000
---> Running in b360b0050182
Removing intermediate container b360b0050182
---> 4a550b4ecbdc
Step 7/8 : WORKDIR /opt/requestbin
Removing intermediate container 416d34676426
---> 3d6af8d85ffa
Step 8/8 : CMD gunicorn -b 0.0.0.0:8000 --worker-class gevent --workers 2 --max-requests 1000 requestbin:app
---> Running in da2a42b95fca
Removing intermediate container da2a42b95fca
---> 8840f59e26d9
Successfully built 8840f59e26d9
Successfully tagged requestbin_app:latest
[root@c720120 requestbin]# docker-compose up -d
Creating requestbin_redis_1 ... done
Creating requestbin_app_1 ... done
(3)打开浏览器,打开如下图所示:
2. 执行步骤:
(1). 作为项目的拥有者登陆GitLab服务器。
(2). 进入到你想要打开webhook的项目。
(3)点击【Settings】-【Integrations】,打开如下画面。
(4)打开RequestsBin服务器,点击【Create a RequestBin】
(5)会打开如下画面,复制URL。
(6)把复制的URL粘贴如下。然后点击【Add webhook】
Gitlab Webhooks, External Services, and API(二)的更多相关文章
- Gitlab Webhooks, External Services, and API(一)
一. 和外部服务进行集成 Gitlab支持和不同的外部服务进行集成,比如可以和聊天工具,Slack或者Campfire进行集成,或者和项目管理工具进行集成.如Assembla或者Pivotal Tra ...
- SharePoint 2013 Excel Services REST API介绍
前言:Excel Services 中的 REST API 是 Microsoft SharePoint Server 2010 的新增项.利用 REST API,可通过 URL 直接访问工作簿部件或 ...
- 第四十一章 微服务CICD(3)- jenkins + gitlab + webhooks + publish-over-ssh(1)
一.作用 使用webhooks来实现当git客户端push代码到gitlab后,jenkins会立即去gitlab拉取代码并构建. 二.步骤 1.安装插件 ruby_runtime(Hook插件依赖于 ...
- Civil 3D API二次开发学习指南
Civil 3D构建于AutoCAD 和 Map 3D之上,在学习Civil 3D API二次开发之前,您至少需要了解AutoCAD API的二次开发,你可以参考AutoCAD .NET API二次开 ...
- 用JSON-server模拟REST API(二) 动态数据
用JSON-server模拟REST API(二) 动态数据 上一篇演示了如何安装并运行 json server , 在这里将使用第三方库让模拟的数据更加丰满和实用. 目录: 使用动态数据 为什么选择 ...
- Express4.x API (二):Request (译)
写在前面 最近学习express想要系统的过一遍API,www.expressjs.com是express英文官网(进入www.epxressjs.com.cn发现也是只有前几句话是中文呀~~),所以 ...
- Linux -- 基于zookeeper的java api(二)
Linux -- 基于zookeeper的java api(二) 写一个关于基于集群的zookeeper的自定义实现HA 基于客户端和监控器:使用监控的方法查看每个注册过的节点的状态来做出操作. Wa ...
- 百度地图API二:根据标注点坐标范围计算显示缩放级别zoom自适应显示地图
原文:百度地图API二:根据标注点坐标范围计算显示缩放级别zoom自适应显示地图 版权声明:本文为博主原创文章,转载请注明出处. https://blog.csdn.net/liusaint1992/ ...
- Day029 JDK8中新日期和时间API (二)
# JDK8中新日期和时间API (二) Instant介绍 Instant:时间线上的一个瞬时点. 这可能被用来记录应用程序中的事件时间 戳. 在处理时间和日期的时候,我们通常会想到年,月,日,时, ...
随机推荐
- CJB的大作
Description 给你一个长度不超过100的字符串.一共进行\(N\)次操作,第\(i\)次操作是将当前字符串复制一份接到后面,并将新的一份循环移位\(k_i\)(\(1 \le k_i \le ...
- 40+ 个非常有用的 Oracle 查询语句
40+ 个非常有用的 Oracle 查询语句,主要涵盖了日期操作,获取服务器信息,获取执行状态,计算数据库大小等等方面的查询.这些是所有 Oracle 开发者都必备的技能,所以快快收藏吧! 日期/时间 ...
- Luogu 1613 跑路(最短路径,倍增)
Luogu 1613 跑路(最短路径,倍增) Description 小A的工作不仅繁琐,更有苛刻的规定,要求小A每天早上在6:00之前到达公司,否则这个月工资清零.可是小A偏偏又有赖床的坏毛病.于是 ...
- C++并发编程实战---阅读笔记
1. 当把函数对象传入到线程构造函数中时,需要避免“最令人头痛的语法解析”.如果传递了一个临时变量,而不是一个命名的变量:C++编译器会将其解析为函数声明,而不是类型对象的定义. 例如: class ...
- spring task 实现定时执行(补充:解决定时任务执行2次问题)
首先在spring-mvc.xml配置头文件引入: xmlns:task="http://www.springframework.org/schema/task" 其次引入task ...
- linux c 编程 ------ 常见函数
fork():创建一个进程 exec():停止当前进程中程序的执行,让当前进程执行另一个程序 access():查看是否有操作文件的权限,可以用来判断一个文件是否存在 pipe():无名管道,用在父子 ...
- 开发环境--Pipenv的使用
1.Pipenv 介绍 Pipenv是基于pip的Python包管理工具,它和pip的用法非常相似,可以看做pip的加强版. pipenv解决了旧的pip+virtualenv+requirement ...
- python Popen卡死问题
程序经常卡死,定位了半天才定位到原因,原来是Popen导致的卡死: 程序如下: s = subprocess.Popen([*,*,*], stdout=subprocess.PIPE) ret = ...
- centos下安装python3.6.2
一.下载 官网地址:https://www.python.org/downloads/source/ 我下载的是最新的3.6.2rc版本 # cd /opt/ wget https://www.pyt ...
- bzoj千题计划183:bzoj1197: [HNOI2006]花仙子的魔法
http://www.lydsy.com/JudgeOnline/problem.php?id=1197 题意转化:在n维空间中放m个n维球,问最多将空间分成几部分 f[i][j] 表示在i维空间中放 ...