使用Generic Webhook Trigger插件实现Jenkins+WebHooks(Gogs)持续集成--指定分支和Commit message进行集成

Jenkins Job配置

使用Generic Webhook Trigger插件实现Jenkins+WebHooks(Gogs)持续集成--指定分支和Commit message进行集成

使用Generic Webhook Trigger插件实现Jenkins+WebHooks(Gogs)持续集成--指定分支和Commit message进行集成

 

请求

Request URL: http://192.168.15.207:8080/generic-webhook-trigger/invoke?token=activity
Request method: POST
Content-Type: application/json
X-Github-Delivery: 911b5a88-fa58-4bdd-a18c-faa02a351ed5
X-Github-Event: push
X-Gogs-Delivery: 911b5a88-fa58-4bdd-a18c-faa02a351ed5
X-Gogs-Event: push
X-Gogs-Signature: 

{
  "ref": "refs/heads/master",
  "before": "245d00a3146cc9388d35a43bfbfbff4f55bf2c90",
  "after": "15a725c335c40c948071cf93ec3a284f4b27fdaa",
  "compare_url": "http://git.yun.cn/ailgiP/activity/compare/245d00a3146cc9388d35a43bfbfbff4f55bf2c90...15a725c335c40c948071cf93ec3a284f4b27fdaa",
  "commits": [
    {
      "id": "15a725c335c40c948071cf93ec3a284f4b27fdaa",
      "message": "更新  -build\n",
      "url": "http://git.yun.cn/activity/commit/15a725c335c40c948071cf93ec3a284f4b27fdaa",
      "author": {
        "name": "xxx",
        "email": "[email protected]",
        "username": "xxx"
      },
      "committer": {
        "name": "xxx",
        "email": "[email protected]",
        "username": "xxx"
      },
      "added": [],
      "removed": [],
      "modified": [
        "NationalDay/index.html"
      ],
      "timestamp": "2019-11-01T15:56:14+08:00"
    }
  ],
  "repository": {
    "id": 573,
    "owner": {
      "id": 20,
      "username": "xxx",
      "login": "xxx",
      "full_name": "",
      "email": "[email protected]",
      "avatar_url": "http://git.yun.cn/avatars/20"
    },
    "name": "activity",
    "full_name": "ailgiP/activity",
    "description": "活动页",
    "private": true,
    "fork": false,
    "parent": null,
    "empty": false,
    "mirror": false,
    "size": 12734464,
    "html_url": "http://git.yun.cn/ailgiP/activity",
    "ssh_url": "ssh://[email protected]:8032/activity.git",
    "clone_url": "http://git.yun.cn/ailgiP/activity.git",
    "website": "",
    "stars_count": 0,
    "forks_count": 0,
    "watchers_count": 1,
    "open_issues_count": 0,
    "default_branch": "master",
    "created_at": "2019-10-29T16:11:48+08:00",
    "updated_at": "2019-11-01T15:22:17+08:00"
  },
  "pusher": {
    "id": 116,
    "username": "xx",
    "login": "xx",
    "full_name": "xx",
    "email": "[email protected]",
    "avatar_url": "https://secure.gravatar.com/avatar/7187277eac97c6a1186babb79b55ba76?d=identicon"
  },
  "sender": {
    "id": 116,
    "username": "xx",
    "login": "xx",
    "full_name": "xxx",
    "email": "[email protected]",
    "avatar_url": "https://secure.gravatar.com/avatar/7187277eac97c6a1186babb79b55ba76?d=identicon"
  }
}

响应

{"status":"ok","data":{"triggerResults":{"activity":{"regexpFilterExpression":"^(refs/heads/master)_(build)$","triggered":true,"resolvedVariables":{"message":"build","ref":"refs/heads/master"},"regexpFilterText":"refs/heads/master_build","id":28,"url":"queue/item/28/"}}}}

参考文章

https://blog.****.net/xlgen157387/article/details/76216351

https://stackoverflow.com/questions/53128992/triggering-build-based-on-commit-message-using-jenkins-webhook-trigger

https://stackoverflow.com/questions/50778526/trigger-a-jenkins-pipeline-by-tagging-an-existing-commit