搜索

6.6. 在 Pipelines as Code 中使用传人(incoming)webhook

download PDF

使用传入的 webhook URL 和共享 secret,您可以在存储库中启动管道运行。

要使用传入的 Webhook,在 Repository 自定义资源定义 (CRD) 的 spec 部分中指定以下内容:

  • Pipelines as Code 匹配的传入 Webhook URL。
  • Git 提供程序和用户令牌。目前,Pipelines as Code 支持 githubgitlabbitbucket-cloud

    注意

    在 GitHub 应用程序上下文中使用传入的 Webhook URL 时,您必须指定令牌。

  • 目标分支和传入 Webhook URL 的 secret。

示例: 带有传入 Webhook 的 Repository CRD

apiVersion: "pipelinesascode.tekton.dev/v1alpha1"
kind: Repository
metadata:
  name: repo
  namespace: ns
spec:
  url: "https://github.com/owner/repo"
  git_provider:
    type: github
    secret:
      name: "owner-token"
  incoming:
    - targets:
      - main
      secret:
        name: repo-incoming-secret
      type: webhook-url

示例:传入 webhook 的 repo-incoming-secret secret

apiVersion: v1
kind: Secret
metadata:
  name: repo-incoming-secret
  namespace: ns
type: Opaque
stringData:
  secret: <very-secure-shared-secret>

要触发位于 Git 存储库的 .tekton 目录中的管道运行,请使用以下命令:

$ curl -X POST 'https://control.pac.url/incoming?secret=very-secure-shared-secret&repository=repo&branch=main&pipelinerun=target_pipelinerun'

Pipelines as Code 与传入的 URL 匹配,并将其视为 push 事件。但是,Pipelines as Code 不会报告这个命令触发的管道运行的状态。

要获取报告或通知,请将 finally 任务直接添加到您的管道中。另外,您可以使用 tkn pac CLI 工具检查 Repository CRD。

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.