在JFrog平台上创建webhook
要开始创建webhook,请执行以下操作:
- 导航到管理模块|一般| Webhooks并点击新Webhook.
输入以下字段的详细信息:
场 描述 URL
指定Webhook调用的URL。这将是Artifactory发送HTTP POST请求的URL。
使用代理
是否通过代理发送Webhook。您可以从已配置的代理服务器列表中选择代理服务器。 事件
显示Artifactory, Xray和Distribution中作为Webhook事件触发器的事件列表。 秘密令牌
定义秘密身份验证令牌。作为管理员,你可以决定如何使用webhook的secret令牌:
- 使用秘密身份验证令牌作为“X-JFrog-Event-Auth”HTTP标头,以便接收事件的服务可以使用该令牌对事件发射器进行身份验证
- 用于对事件有效负载进行签名——在这种情况下,秘密令牌不能作为标头传递
使用secret进行有效负载签名
如果选中“为有效载荷签名使用秘密”复选框,这个秘密将被用来签署事件有效负载,并将作为“X-JFrog-Event-Auth”HTTP报头传递。
注意,自定义http头在webhook目标端是不可信的——因为它们没有签名,任何中间人都可以篡改它们。
自定义标题
添加您希望用于调用Webhook的自定义标头。
默认情况下,出于安全原因,私有网络不允许用作Webhook目标。如果您希望允许使用私有网络,请修改系统中的URL严格策略配置。yaml文件:
urlStrictPolicy:真
.看到Artifactory系统YAML.- 一些事件可以应用到存储库、构建和发布包:
基于特定列表或使用包含/排除模式,可以在Artifactory中的每个存储库或特定存储库列表上应用工件被部署、移动、添加等事件。
请注意,如果您选择任何本地和/或远程存储库,Webhook将应用于所有现有的存储库和将来创建的存储库。
诸如构建已部署、升级、删除等事件可以应用于上传到Artifactory的每个新构建,或基于特定列表或使用包含/排除模式的特定构建列表。
发布包和分发事件可以应用在每个新的发布包上,也可以应用在特定的发布包列表上,基于特定的列表或使用包含/排除模式。
测试Webhook
属性可以测试Webhook测试按钮,以检查Artifactory和配置的URL之间的连通性。TWebhook将被手动触发,一个虚拟有效载荷将被发送到配置的URL。
事件类型
以下是根据每个域支持的事件类型,并为将发送到配置的URL的有效负载的每个事件提供了示例。
域:工件
包括在Artifactory中发生某些工件事件时触发的事件:
事件:部署
当工件部署到存储库时,Webhook将被触发。您可以选择应用Webhook的存储库和存储库路径。
{"domain": "artifact", "event_type": "deployed", "data": {"repo_key": "example-repo-local", "path": "pipeinfo7. "Json ", "name": "pipeinfo7。Json ", "sha256": "8b6cd18345075ff248487fed24e87ff0acff1454e761cc0676f78fc898dff7a7", "size": 203}, "subscription_key": "jfdev-agent", "source": "jfrog/jfrt@01fsmwgxevmmcr1ajmvhfw1j9s"}
事件:删除
当工件从存储库中删除时,Webhook将被触发。您可以选择应用Webhook的存储库。
{"repo_key":"sample_repo", "path":"sample_path_dir/sample_artifact", "name":"sample_artifact", "sha256":"ec1be623d148ed220f70f4f6125dc738b1d301a85b75e87c5b554fa3bb1b4141", "size":17848}
事件:移动
当工件从存储库中移动时,Webhook将被触发。您可以选择应用Webhook的存储库和存储库路径。Webhook将应用于工件移动的存储库。
{"repo_key":"sample_repo", "path":"sample_path_dir/sample_artifact", "name":"sample_artifact", "size":0, "source_repo_path":"sample_repo/sample_path_dir/sample_artifact", "target_repo_path":"target_repo/sample_path_dir/sample_artifact"}
事件:复制
当从存储库复制工件时,Webhook将被触发。您可以选择应用Webhook的存储库和存储库路径。Webhook将应用于从中复制工件的存储库。
{"repo_key":"sample_repo", "path":"sample_path_dir/sample_artifact", "name":"sample_artifact", "size":0, "source_repo_path":"sample_repo/sample_path_dir/sample_artifact", "target_repo_path":"target_repo/sample_path_dir/sample_artifact"}
事件:缓存
从新的远程存储库中提取的每个工件都会触发Webhook。webhook是在下载远程工件时生成的,例如:NPM安装busybox
.如果webhook可以用于推送复制和下载远程工件,那么它也应该适用于拉式复制。
{"repo_key":"sample_repo", "path":"sample_path_dir/sample_artifact", "name":"sample_artifact", "sha256":"ec1be623d148ed220f70f4f6125dc738b1d301a85b75e87c5b554fa3bb1b4141", "size":17848}
领域:工件属性
包括在Artifactory中发生某些工件属性操作时触发的事件:
事件:添加
当属性被添加到存储库中的工件/文件夹或存储库本身时,Webhook将被触发。您可以选择应用Webhook的存储库和存储库路径。
{"repo_key":"sample_repo", "path":"sample_path_dir/sample_artifact", "name":"sample_artifact", "sha256":"ec1be623d148ed220f70f4f6125dc738b1d301a85b75e87c5b554fa3bb1b4141", "size":17848, "property_key":"sample_prop_key", "property_values":["sample_value"]}
事件:删除
当从存储库中的工件/文件夹或存储库本身删除属性时,Webhook将被触发。您可以选择应用Webhook的存储库和存储库路径。
{"repo_key":"sample_repo", "path":"sample_path_dir/sample_artifact", "name":"sample_artifact", "sha256":"ec1be623d148ed220f70f4f6125dc738b1d301a85b75e87c5b554fa3bb1b4141", "size":17848, "property_key":"sample_prop_key", "property_values":["sample_value"]}
域:码头工人
包括当某些docker相关事件在Artifactory中发生时触发的事件:
事件:推
当Docker映像的新标记被推送到Docker存储库时,Webhook将被触发。你可以选择Docker存储库和应用Webhook的存储库路径。
{"repo_key":"docker-remote-cache", "path":"library/ubuntu/latest/list.manifest. "json”、“名称”:“list.manifest。Json ", "sha256":"35c4a2c15539c6c1e4e5fa4e554dac323ad0107d8eb5c582d6ff386b383b7dce", "size":1206, "image_name":"library/ubuntu", "tag":"latest", "platforms":[{"architecture":"amd64", "os":"linux"}, {"architecture":"arm", "os":"linux"}, {"architecture":"arm64", "os":"linux"}, {"architecture":"ppc64le", "os":"linux"}, {"architecture":"s390x", "os":"linux"}]}
事件:删除
当Docker映像的标签从Docker存储库中删除时,Webhook将被触发。你可以选择Docker存储库和应用Webhook的存储库路径。
{"repo_key": "sample_repo", "path": "path/sample.txt", "name": "sample.txt", "sha256": "sample_checksum", "size": 0, "image_name": "sample_arch", "tag": "sample_image", "platforms": [{"architecture": "sample_os", "os": "sample_tag"}]}
事件:提升
当Docker图像的一个标签被提升时,Webhook被触发。你可以选择Docker存储库和应用Webhook的存储库路径。Webhook将应用于Docker标签被提升的Docker存储库。
{"repo_key": "sample_repo", "path": "path/sample.txt", "name": "sample.txt", "sha256": "sample_checksum", "size": 0, "image_name": "sample_arch", "tag": "sample_image", "platforms": [{"architecture": "sample_os", "os": "sample_tag"}]}
域:构建
包括当某些构建相关事件在Artifactory中发生时触发的事件:
事件:上传
Webhook在上传新版本时被触发。您可以选择Webhook将应用于其上的构建名称或构建模式。
{"build_name":"sample_build_name", "build_number":"1", "build_started": "2020-06-18T14:40:49.869+0300"}}
事件:删除
当一个构建被删除时,Webhook被触发。您可以选择Webhook将应用于其上的构建名称或构建模式。
{"build_name":"sample_build_name", "build_number":"1", "build_started": "2020-06-18T14:40:49.869+0300"}}
事件:提升
当一个构建被提升时,Webhook将被触发。您可以选择Webhook将应用于其上的构建名称或构建模式。
{"build_name":"sample_build_name", "build_number":"1", "build_started": "2020-06-18T14:40:49.869+0300"}}
域名:发布包
包括当Artifactory中发生某些Release Bundle事件时触发的事件:
事件:创建
Webhook在创建Release Bundle时被触发。你可以选择Webhook应用的发布包名称或模式。
{"destination": "release_bundle", "event_type": "created", "data": {"release_bundle_name": "sample_name", "release_bundle_size": 9800, "release_bundle_version": "1.0.0"}, "jpd_origin": "https://dist-pipe2.jfrogdev "。有限公司/ artifactory "}
事件:签署
当一个发布包被签署时,Webhook被触发。你可以选择Webhook应用的发布包名称或模式。
{"destination": "release_bundle", "event_type": "signed", "data": {"release_bundle_name": "sample_name", "release_bundle_size": 9800, "release_bundle_version": "1.0.0"}, "jpd_origin": "https://dist-pipe2.jfrogdev "。有限公司/ artifactory "}
事件:删除
当Release Bundle被删除时,Webhook将被触发。你可以选择Webhook应用的发布包名称或模式。
{"destination": "release_bundle", "event_type": "deleted", "data": {"release_bundle_name": "sample_name", "release_bundle_size": 9800, "release_bundle_version": "1.0.0"}, "jpd_origin": "https://dist-pipe2.jfrogdev "。有限公司/ artifactory "}
域:分布
包括当发布包版本被分发到一个或多个边缘节点时触发的事件。
事件:distribute_started
Webhook在Release Bundle分发开始时被触发。
{"destination": "distribution", "event_type": "distribute_started", "data": {"edge_node_info_list": [{"edge_node_address": "https://artifactory-edge2-dev.jfrogdev. "Co /artifactory", "edge_node_name": "artifactory-edge2"}, {"edge_node_address": "https://artifactory-edge1-dev.jfrogdev。co/artifactory", "edge_node_name": "artifactory-edge1"}], "release_bundle_name": "test", "release_bundle_size": 1037976, "release_bundle_version": "1.0.0", "status_message": "CREATED", "transaction_id": 395969746957422600}, "jpd_origin": "https://ga-dev.jfrogdev "。有限公司/ artifactory "}
事件:distribute_completed
Webhook在Release Bundle分发完成时被触发。
{"destination": distribution, "event_type": distribute_completed, "data": {"edge_node_info_list": [{"edge_node_address": "https://artifactory-edge2-dev.jfrogdev. "Co /artifactory", "edge_node_name": "artifactory-edge2"}, {"edge_node_address": "https://artifactory-edge1-dev.jfrogdev。co/artifactory", "edge_node_name": "artifactory-edge1"}], "release_bundle_name": "test", "release_bundle_size": 1037976, "release_bundle_version": "1.0.0", "status_message": "CREATED", "transaction_id": 395969746957422600}, "jpd_origin": "https://ga-dev.jfrogdev "。有限公司/ artifactory "}
事件:distribute_aborted
当Release Bundle分发被中止时,Webhook将被触发。
{"destination": "distribution", "event_type": "distribute_aborted", "data": {"edge_node_info_list": [{"edge_node_address": "https://artifactory-edge2-dev.jfrogdev. "Co /artifactory", "edge_node_name": "artifactory-edge2"}, {"edge_node_address": "https://artifactory-edge1-dev.jfrogdev。co/artifactory", "edge_node_name": "artifactory-edge1"}], "release_bundle_name": "test", "release_bundle_size": 1037976, "release_bundle_version": "1.0.0", "status_message": "CREATED", "transaction_id": 395969746957422600}, "jpd_origin": "https://ga-dev.jfrogdev "。有限公司/ artifactory "}
事件:distribute_failed
当发布包分发失败时,Webhook将被触发。
{"destination": "distribution", "event_type": "distribute_failed", "data": {"edge_node_info_list": [{"edge_node_address": "https://artifactory-edge2-dev.jfrogdev. "Co /artifactory", "edge_node_name": "artifactory-edge2"}, {"edge_node_address": "https://artifactory-edge1-dev.jfrogdev。co/artifactory", "edge_node_name": "artifactory-edge1"}], "release_bundle_name": "test", "release_bundle_size": 1037976, "release_bundle_version": "1.0.0", "status_message": "CREATED", "transaction_id": 395969746957422600}, "jpd_origin": "https://ga-dev.jfrogdev "。有限公司/ artifactory "}
事件:deletion_started
时触发Webhook已在一个或多个Edge节点上开始删除Release Bundle版本。
{"destination": "distribution", "event_type": "deletion_started", "data": {"edge_node_info_list": [{"edge_node_address": "https://artifactory-edge2-dev.jfrogdev. "Co /artifactory", "edge_node_name": "artifactory-edge2"}, {"edge_node_address": "https://artifactory-edge1-dev.jfrogdev。co/artifactory", "edge_node_name": "artifactory-edge1"}], "release_bundle_name": "test", "release_bundle_size": 1037976, "release_bundle_version": "1.0.0", "status_message": "CREATED", "transaction_id": 395969746957422600}, "jpd_origin": "https://ga-dev.jfrogdev "。有限公司/ artifactory "}
事件:deletion_completed
时触发Webhook已完成从一个或多个Edge节点上删除Release Bundle版本。
{"destination": "distribution", "event_type": "deletion_completed", "data": {"edge_node_info_list": [{"edge_node_address": "https://artifactory-edge2-dev.jfrogdev. "Co /artifactory", "edge_node_name": "artifactory-edge2"}, {"edge_node_address": "https://artifactory-edge1-dev.jfrogdev。co/artifactory", "edge_node_name": "artifactory-edge1"}], "release_bundle_name": "test", "release_bundle_size": 1037976, "release_bundle_version": "1.0.0", "status_message": "CREATED", "transaction_id": 395969746957422600}, "jpd_origin": "https://ga-dev.jfrogdev "。有限公司/ artifactory "}
事件:deletion_failed
时触发Webhook一个或多个Edge节点上的Release Bundle版本删除失败。
{"destination": "distribution", "event_type": "deletion_failed", "data": {"edge_node_info_list": [{"edge_node_address": "https://artifactory-edge2-dev.jfrogdev. "Co /artifactory", "edge_node_name": "artifactory-edge2"}, {"edge_node_address": "https://artifactory-edge1-dev.jfrogdev。co/artifactory", "edge_node_name": "artifactory-edge1"}], "release_bundle_name": "test", "release_bundle_size": 1037976, "release_bundle_version": "1.0.0", "status_message": "CREATED", "transaction_id": 395969746957422600}, "jpd_origin": "https://ga-dev.jfrogdev "。有限公司/ artifactory "}
域:目的地
包括当边缘节点上的发布包状态改变时触发的事件。
需要Artifactory 7.15.1及以上版本。
事件:收到
当边缘节点上接收到Release Bundle时,Webhook将被触发。
{"destination": "artifactory_release_bundle", "event_type": "received", "data": {"release_bundle_name": "test", "release_bundle_version": "1.0.0", "status_message": "COMPLETED}, "jpd_origin": "https://dist-pipe2.jfrogdev "。有限公司/ artifactory "}
事件:delete_started
当边缘节点的Release Bundle删除完成时,Webhook将被触发。
{"destination": "artifactory_release_bundle", "event_type": "delete_started", "data": {"release_bundle_name": "test", "release_bundle_version": "1.0.0", "status_message": "COMPLETED}, "jpd_origin": "https://dist-pipe2.jfrogdev "。有限公司/ artifactory "}
事件:delete_completed
当边缘节点的Release Bundle删除完成时,Webhook将被触发。
{"destination": "artifactory_release_bundle", "event_type": "delete_completed", "data": {"release_bundle_name": "test", "release_bundle_version": "1.0.0", "status_message": "COMPLETED}, "jpd_origin": "https://dist-pipe2.jfrogdev。有限公司/ artifactory "}
事件:delete_failed
当边缘节点的Release Bundle删除失败时,Webhook将被触发。
{"destination": "artifactory_release_bundle", "event_type": "delete_failed", "data": {"release_bundle_name": "test", "release_bundle_version": "1.0.0", "status_message": "COMPLETED}, "jpd_origin": "https://dist-pipe2.jfrogdev "。有限公司/ artifactory "}
Webhooks REST API支持
要使用REST API创建、更新和删除webhook,请参见人的api.