php-censor / php-censor

PHP Censor is an open source self-hosted continuous integration server for PHP projects.

Home Page:http://php-censor.info

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature] Add Webhook for Gitea

kromonos opened this issue · comments

Gitea Webhook

I tried several methods to activate hooks from Gitea. With a gogs type I get

{"status":"failed","commits":{"1112d76c11dc52602f1b4e71006454a24e748e68":{"status":"failed","error":"SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`kromonossql14`.`builds`, CONSTRAINT `builds_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE)"}}}`

Other webhook types run into unusable payload or just {"status":"failed","commits":[]}

More about Gitea webhooks can be found at https://docs.gitea.io/en-us/webhooks/

@kromonos Could you additionally give more details like your payload for PHP Censor from Gitea (Without secrets)?

Gitea sends following payload:

{
  "secret": "",
  "ref": "refs/heads/master",
  "before": "1112d76c11dc52602f1b4e71006454a24e748e68",
  "after": "1112d76c11dc52602f1b4e71006454a24e748e68",
  "compare_url": "",
  "commits": [
    {
      "id": "1112d76c11dc52602f1b4e71006454a24e748e68",
      "message": "Fixed the text about the dumbasses\n",
      "url": "https://code.bka.li/kromonos/teleyal/commit/1112d76c11dc52602f1b4e71006454a24e748e68",
      "author": {
        "name": "Kromonos",
        "email": "k@bka.li",
        "username": ""
      },
      "committer": {
        "name": "Kromonos",
        "email": "k@bka.li",
        "username": ""
      },
      "verification": null,
      "timestamp": "0001-01-01T00:00:00Z",
      "added": null,
      "removed": null,
      "modified": null
    }
  ],
  "head_commit": null,
  "repository": {
    "id": 4,
    "owner": {
      "id": 1,
      "login": "kromonos",
      "full_name": "Kromonos",
      "email": "kromonos@noreply.bka.li",
      "avatar_url": "https://code.bka.li/user/avatar/kromonos/-1",
      "language": "en-US",
      "is_admin": true,
      "last_login": "2020-07-16T09:51:53+02:00",
      "created": "2020-07-15T00:06:29+02:00",
      "username": "kromonos"
    },
    "name": "teleyal",
    "full_name": "kromonos/teleyal",
    "description": "",
    "empty": false,
    "private": true,
    "fork": false,
    "template": false,
    "parent": null,
    "mirror": false,
    "size": 67672,
    "html_url": "https://code.bka.li/kromonos/teleyal",
    "ssh_url": "git@code.bka.li:kromonos/teleyal.git",
    "clone_url": "https://code.bka.li/kromonos/teleyal.git",
    "original_url": "",
    "website": "https://teleyal.blog",
    "stars_count": 0,
    "forks_count": 0,
    "watchers_count": 1,
    "open_issues_count": 0,
    "open_pr_counter": 0,
    "release_counter": 0,
    "default_branch": "master",
    "archived": false,
    "created_at": "2020-07-15T15:39:58+02:00",
    "updated_at": "2020-07-19T18:49:28+02:00",
    "permissions": {
      "admin": false,
      "push": false,
      "pull": false
    },
    "has_issues": true,
    "internal_tracker": {
      "enable_time_tracker": false,
      "allow_only_contributors_to_track_time": true,
      "enable_issue_dependencies": true
    },
    "has_wiki": false,
    "has_pull_requests": false,
    "ignore_whitespace_conflicts": false,
    "allow_merge_commits": false,
    "allow_rebase": false,
    "allow_rebase_explicit": false,
    "allow_squash_merge": false,
    "avatar_url": "https://code.bka.li/repo-avatars/4-00a5f3ff2e5873147ca0dab3f36389e0",
    "internal": false
  },
  "pusher": {
    "id": 1,
    "login": "kromonos",
    "full_name": "Kromonos",
    "email": "kromonos@noreply.bka.li",
    "avatar_url": "https://code.bka.li/user/avatar/kromonos/-1",
    "language": "en-US",
    "is_admin": true,
    "last_login": "2020-07-16T09:51:53+02:00",
    "created": "2020-07-15T00:06:29+02:00",
    "username": "kromonos"
  },
  "sender": {
    "id": 1,
    "login": "kromonos",
    "full_name": "Kromonos",
    "email": "kromonos@noreply.bka.li",
    "avatar_url": "https://code.bka.li/user/avatar/kromonos/-1",
    "language": "en-US",
    "is_admin": true,
    "last_login": "2020-07-16T09:51:53+02:00",
    "created": "2020-07-15T00:06:29+02:00",
    "username": "kromonos"
  }
}

Hello,

I success to configure gitea to execute a build.
My Gitea version is v1.13.0 and I configure a "gitea" type of hook, I set the url of my PHP CENSOR with "?branch=XXX", HTTP method "GET" and with the branch filter.

I have not dynamically other variable. I use the environment settings in my case.

Is it possible to add the environment settings in the webhook ?

I send a POST instead GET, because I have an error "414 Request-URI Too Large"

I just set it up too. Using on Gitea a Gitea Webhook with POST request to the URL [php-censor.url]/webhook/gogs/​[pid] and configured my Project for a gog hook. Works perfectly.

Gitea Version: 1.13.6
PHP Censor: v2.0.2

@gnomii Could you create new issue for the environment settings in a webhook with detailed description of the feature?
@kromonos Can I close the issue?

@kromonos Can I close the issue?

As it works, the issue is done 😊