Webhook
目錄
您可以使用 Webhook 在儲存庫發生推送事件時,觸發另一個服務中的動作。Webhook 是傳送到您在 Docker Hub 中定義的 URL 的 POST 請求。
建立 Webhook
建立 Webhook 的步驟
- 在您選擇的儲存庫中,選取**Webhook**索引標籤。
- 為 Webhook 提供名稱。
- 提供目標 Webhook URL。這是 Webhook POST 請求的傳遞位置。
- 選取**建立**。
檢視 Webhook 傳遞記錄
檢視 Webhook 記錄的步驟
- 將滑鼠懸停在**目前 Webhook 區段**下的 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"
}
}