Webhooks
目录
您可以使用webhooks来响应仓库中的推送事件,从而在另一个服务中触发一个动作。Webhooks是发送到您在Docker Hub中定义的URL的POST请求。
创建一个webhook
要创建一个webhook:
- 在您选择的仓库中,选择Webhooks标签。
- 为webhook提供一个名称。
- 提供一个目标webhook URL。这是webhook POST请求被传递的地方。
- 选择创建。
查看webhook交付历史
查看webhook的历史记录:
- 将鼠标悬停在当前Webhooks部分下的您的webhook上。
- 选择菜单选项图标。
- 选择查看历史。
然后您可以查看交付历史,以及POST请求的交付是否成功。
示例webhook负载
Webhook 负载具有以下 JSON 格式:
{
"callback_url": "https://registry.hub.docker.com/u/svendowideit/testhook/hook/2141b5bi5i5b02bec211i4eeih0242eg11000a/",
"push_data": {
"pushed_at": 1417566161,
"pusher": "trustedbuilder",
"tag": "latest"
},
"repository": {
"comment_count": 0,
"date_created": 1417494799,
"description": "",
"dockerfile": "#\n# BUILD\u0009\u0009docker build -t svendowideit/apt-cacher .\n# RUN\u0009\u0009docker run -d -p 3142:3142 -name apt-cacher-run apt-cacher\n#\n# and then you can run containers with:\n# \u0009\u0009docker run -t -i -rm -e http_proxy http://192.168.1.2:3142/ debian bash\n#\nFROM\u0009\u0009ubuntu\n\n\nVOLUME\u0009\u0009[/var/cache/apt-cacher-ng]\nRUN\u0009\u0009apt-get update ; apt-get install -yq apt-cacher-ng\n\nEXPOSE \u0009\u00093142\nCMD\u0009\u0009chmod 777 /var/cache/apt-cacher-ng ; /etc/init.d/apt-cacher-ng start ; tail -f /var/log/apt-cacher-ng/*\n",
"full_description": "Docker Hub based automated build from a GitHub repo",
"is_official": false,
"is_private": true,
"is_trusted": true,
"name": "testhook",
"namespace": "svendowideit",
"owner": "svendowideit",
"repo_name": "svendowideit/testhook",
"repo_url": "https://registry.hub.docker.com/u/svendowideit/testhook/",
"star_count": 0,
"status": "Active"
}
}