zoukankan      html  css  js  c++  java
  • adnanh webhook 框架 hook rule

    adnanh webhook 支持一系列的逻辑操作

    AND

    所有的条件都必须匹配

    {
    "and":
      [
        {
          "match":
          {
            "type": "value",
            "value": "refs/heads/master",
            "parameter":
            {
              "source": "payload",
              "name": "ref"
            }
          }
        },
        {
          "match":
          {
            "type": "regex",
            "regex": ".*",
            "parameter":
            {
              "source": "payload",
              "name": "repository.owner.name"
            }
          }
        }
      ]
    }

    OR

    匹配条件中有一个为true 即可

    {
    "or":
      [
        {
          "match":
          {
            "type": "value",
            "value": "refs/heads/master",
            "parameter":
            {
              "source": "payload",
              "name": "ref"
            }
          }
        },
        {
          "match":
          {
            "type": "value",
            "value": "refs/heads/development",
            "parameter":
            {
              "source": "payload",
              "name": "ref"
            }
          }
        }
      ]
    }

    NOT

    为false 是执行

    {
    "not":
      {
        "match":
        {
          "type": "value",
          "value": "refs/heads/development",
          "parameter":
          {
            "source": "payload",
            "name": "ref"
          }
        }
      }
    }

    混合

    {
        "and": [
        {
            "match": {
                "parameter": {
                    "source": "header",
                    "name": "X-Hub-Signature"
                },
                "type": "payload-hash-sha1",
                "secret": "mysecret"
            }
        },
        {
            "or": [
            {
                "match":
                {
                    "parameter":
                    {
                        "source": "payload",
                        "name": "ref"
                    },
                    "type": "value",
                    "value": "refs/heads/master"
                }
            },
            {
                "match":
                {
                    "parameter":
                    {
                        "source": "header",
                        "name": "X-GitHub-Event"
                    },
                    "type": "value",
                    "value": "ping"
                }
            }
            ]
        }
        ]
    }

    match 原则

    • 值匹配
    {
      "match":
      {
        "type": "value",
        "value": "refs/heads/development",
        "parameter":
        {
          "source": "payload",
          "name": "ref"
        }
      }
    }
    • 正则匹配
    {
      "match":
      {
        "type": "regex",
        "regex": ".*",
        "parameter":
        {
          "source": "payload",
          "name": "ref"
        }
      }
    }
    • hash sha1 算法匹配
    {
      "match":
      {
        "type": "payload-hash-sha1",
        "secret": "yoursecret",
        "parameter":
        {
          "source": "header",
          "name": "X-Hub-Signature"
        }
      }
    }
    • ip 白名单匹配
    {
      "match":
      {
        "type": "ip-whitelist",
        "ip-range": "192.168.0.1/24"
      }
    }

    参考资料

    https://github.com/adnanh/webhook/blob/master/docs/Hook-Rules.md

  • 相关阅读:
    JAVA反射机制--静态加载与动态加载
    MyEclipse导入Hibernate出现Path must include project and resource;/project name
    服务器和java程序的桥梁--jdbc/hibernate
    AndroidStudio快捷键大全
    AndroidStudio怎么实现微信分享功能
    《一面》
    java泛型
    java设计模式-Observer(2)
    java设计模式-Observe
    HashSet的自定义实现
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/9703592.html
Copyright © 2011-2022 走看看