在JFrog平台上创建webhook
要开始创建webhook,请执行以下操作:
- 导航到管理模块|通用| Webhooks并点击新Webhook.
输入以下字段的详细信息:
场 描述 URL
指定Webhook调用的URL。这将是Artifactory将向其发送HTTP POST请求的URL。
使用代理
是否通过代理发送Webhook。您可以从已配置的代理服务器列表中选择代理。 事件
显示Artifactory、Xray和Distribution中作为Webhook事件触发器的事件列表。 秘密令牌
定义一个秘密身份验证令牌。作为一个管理员,你可以决定webhook的秘密令牌应该使用的方式:
- 使用秘密身份验证令牌作为“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 ", "name": "pipeinfo7. Json "。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"]}
域:码头工人
包括在Artifactory中发生某些与docker相关的事件时触发的事件:
事件:推
当Docker映像的新标签被推送到Docker存储库中时,Webhook会被触发。您可以选择Docker存储库和存储库路径,Webhook将在其上应用。
{"repo_key":"docker-remote-cache", "path":"library/ubuntu/latest/list.manifest. conf "。json”、“名称”:“list.manifest。Json ", "sha256":"35c4a2c15539c6c1e4e5fa4e554dac323ad0107d8eb5c582d6ff386b383b7dce", "size":1206, "image_name":"library/ubuntu", "tag":"latest", "platforms":[{"architecture":"amd64", "os":"linux"}, {"architecture":"arm", "os":"linux"}, {"architecture":"ppc64le", "os":"linux"}, {"architecture":"ppc64le", "os":"linux"}, {"architecture":"s390x", "os":"linux"}, {"architecture":"s390x", "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": " 20-06-18t14:40:49.869+0300"}}
事件:删除
当一个构建被删除时,Webhook将被触发。您可以选择Webhook将应用于其上的构建名称或构建模式。
{"build_name":"sample_build_name", "build_number":"1", "build_started": " 20-06-18t14:40:49.869+0300"}}
事件:提升
当构建被提升时,Webhook会被触发。您可以选择Webhook将应用于其上的构建名称或构建模式。
{"build_name":"sample_build_name", "build_number":"1", "build_started": " 20-06-18t14:40:49.869+0300"}}
领域:发布包
包括当某些发布包事件在Artifactory中发生时触发的事件:
事件:创建
当Release Bundle被创建时,Webhook会被触发。您可以选择应用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. co/artifactory", "edge_node_name": "artifactory-edge1"}],有限公司/ 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. co/artifactory", "edge_node_name": "artifactory-edge1"}],有限公司/ 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. co/artifactory", "edge_node_name": "artifactory-edge1"}],有限公司/ 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. co/artifactory", "edge_node_name": "artifactory-edge1"}],有限公司/ artifactory "}
事件:deletion_started
时触发Webhook已经开始在一个或多个边缘节点上删除发布包版本。
{"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. co/artifactory", "edge_node_name": "artifactory-edge1"}],有限公司/ artifactory "}
事件:deletion_completed
时触发Webhook从一个或多个边缘节点删除发布包版本已经完成。
{"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. co/artifactory", "edge_node_name": "artifactory-edge1"}],有限公司/ artifactory "}
事件:deletion_failed
时触发Webhook在一个或多个边缘节点上删除发布包版本失败。
{"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. co/artifactory", "edge_node_name": "artifactory-edge1"}],有限公司/ 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
当从边缘节点删除发布包失败时,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.