【问题标题】:Getting the github webhook payload information inside Jenkins pipeline在 Jenkins 管道中获取 github webhook 有效负载信息
【发布时间】:2016-07-28 19:05:31
【问题描述】:

我需要通过 Jenkinsfile 访问管道作业中的 github webhook 有效负载信息。我可以使用以下 sn-p 打印有效负载:

properties ( [[$class: 'ParametersDefinitionProperty', parameterDefinitions: [[$class: 'StringParameterDefinition', defaultValue: '', description: '', name: 'payload']]]] )
echo ("This build is built with the payload: $payload")

但这只有在我为该特定工作定义了 webhook 时才有效,如下所示:

http://<jenkins url>/job/Demo_GitHubOrg/job/DemoRepo/branch/master//buildWithParameters

我的管道作业扫描给定的组织并自动创建作业/repo/branch。

有没有办法编写一个更通用的 webhook,它适用于我的管道文件夹中的所有作业,而不是为每个作业编写一个,如上所示?

【问题讨论】:

  • 您需要 webhook 中包含的哪些信息?
  • 提交者名称、提交哈希等信息。
  • 从本地 Git 历史记录中获取它们
  • 我可以对此使用答案,如果当前提交状态未通过,我希望我的管道停止并发布 PR 评论
  • 我是一个信息,比如谁推送到了作为推送字段一部分的存储库的提交

标签: jenkins jenkins-pipeline


【解决方案1】:

有没有办法编写一个适用于所有人的更通用的 webhook 我的管道文件夹中的作业,而不是为每个作业编写一个 如上所示?

是的,Generic Webhook Trigger Plugin。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多