Closed Dual-0 closed 2 years ago
Perhaps the request body is formatted in an unexpected manner? Can you try replacing the following line:
this.logger.info(`Unknown Gitea action: '${body.action}'`);
With this?
this.logger.info(`Gitea webhook body: '${JSON.stringify(body)}'`);
hope this helps
Gitea webhook body: '{"ref":"refs/heads/master","before":"009a21d2d7a6120c0c8b64c6313b4a57335b784e","after":"009a21d2d7a6120c0c8b64c6313b4a57335b784e","compare_url":"","commits":[{"id":"009a21d2d7a6120c0c8b64c6313b4a57335b784e","message":"update iconTheme extension\n","url":"https://git.domain.com/myusername/MY_Repo/commit/009a21d2d7a6120c0c8b64c6313b4a57335b784e","author":{"name":"myusername","email":"myusername@mail.com","username":""},"committer":{"name":"myusername","email":"myusername@mail.com","username":""},"verification":null,"timestamp":"0001-01-01T00:00:00Z","added":null,"removed":null,"modified":null}],"head_commit":{"id":"009a21d2d7a6120c0c8b64c6313b4a57335b784e","message":"update iconTheme extension\n","url":"https://git.domain.com/myusername/MY_Repo/commit/009a21d2d7a6120c0c8b64c6313b4a57335b784e","author":{"name":"myusername","email":"myusername@mail.com","username":""},"committer":{"name":"myusername","email":"myusername@mail.com","username":""},"verification":null,"timestamp":"0001-01-01T00:00:00Z","added":null,"removed":null,"modified":null},"repository":{"id":10,"owner":{"id":1,"login":"myusername","full_name":"myusername","email":"myusername@mail.com","avatar_url":"https://git.domain.com/user/avatar/myusername/-1","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2021-01-30T17:08:17+01:00","restricted":false,"active":false,"prohibit_login":false,"location":"","website":"","description":"","visibility":"public","followers_count":0,"following_count":0,"starred_repos_count":0,"username":"myusername"},"name":"MY_Repo","full_name":"myusername/MY_Repo","description":"","empty":false,"private":true,"fork":false,"template":false,"parent":null,"mirror":false,"size":38,"html_url":"https://git.domain.com/myusername/MY_Repo","ssh_url":"git@git.domain.com:myusername/MY_Repo.git","clone_url":"https://git.domain.com/myusername/MY_Repo.git","original_url":"","website":"","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":"2021-08-14T20:32:06+02:00","updated_at":"2021-10-16T12:00:46+02:00","permissions":{"admin":false,"push":false,"pull":false},"has_issues":false,"has_wiki":false,"has_pull_requests":false,"has_projects":false,"ignore_whitespace_conflicts":false,"allow_merge_commits":false,"allow_rebase":false,"allow_rebase_explicit":false,"allow_squash_merge":false,"default_merge_style":"merge","avatar_url":"https://git.domain.com/repo-avatars/10-c7a07ea4eeed3ad67dcb5a8e42ac9f9a","internal":false,"mirror_interval":""},"pusher":{"id":1,"login":"myusername","full_name":"myusername","email":"myusername@mail.com","avatar_url":"https://git.domain.com/user/avatar/myusername/-1","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2021-01-30T17:08:17+01:00","restricted":false,"active":false,"prohibit_login":false,"location":"","website":"","description":"","visibility":"public","followers_count":0,"following_count":0,"starred_repos_count":0,"username":"myusername"},"sender":{"id":1,"login":"myusername","full_name":"myusername","email":"myusername@mail.com","avatar_url":"https://git.domain.com/user/avatar/myusername/-1","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2021-01-30T17:08:17+01:00","restricted":false,"active":false,"prohibit_login":false,"location":"","website":"","description":"","visibility":"public","followers_count":0,"following_count":0,"starred_repos_count":0,"username":"myusername"}}'
That definitely does help, it looks like the 'secret' field may be missing sometimes. I've made it an optional field.
You can pull the latest Docker image for the :dev
tag to try it out. Could you let me know if this fixes your issue?
yes for sure. My ansible script grabs the new girtea.ts tonight.
Oct 19 23:42:39 HOSTNAME node[1979113]: 2021-10-19 21:42:39.141.000 INFO [plg-gitea] Unknown Gitea action: 'undefined'
Oct 19 23:46:46 HOSTNAME node[1979113]: 2021-10-19 21:46:46.504.000 INFO [plg-gitea] Unknown Gitea action: 'undefined'
1st one was the intregratet webhook test in gitea. The 2nd one was a push to my repo.
I've created a test from your webhook content to check for any other issues with deserialisation, apparently the internal_tracker
field is optional as well, so I've updated the plugin to reflect that.
If you update the plugin again, it should work now (the test successfully parses the JSON you've posted above).
now it works. Thanks for the quick help. Two more things I found out:
only one message is sent even if multiple commits are submitted.
"commits": [
{
"id": "59202873c751aa34dc16f2c913295c4787834ba5",
"message": "add matrix-webhook as part of matrix-service\n",
"url": "https://git.domain.com/username/MyRepo/commit/59202873c751aa34dc16f2c913295c4787834ba5",
"author": {
"name": "username",
"email": "mail@domain.com",
"username": "username"
},
"committer": {
"name": "username",
"email": "mail@domain.com",
"username": "username"
},
"verification": null,
"timestamp": "2021-10-19T22:43:21+02:00",
"added": [],
"removed": [],
"modified": [
"roles/matrix_synapse/templates/matrix-webhook-gateway.service.j2"
]
},
{
"id": "d3f90ba2e7fb89fbcdd12b66e30c3d9add1bc9a6",
"message": "add option to install pip packages via python role\n",
"url": "https://git.domain.com/username/MyRepo/commit/d3f90ba2e7fb89fbcdd12b66e30c3d9add1bc9a6",
"author": {
"name": "username",
"email": "mail@domain.com",
"username": "username"
},
"committer": {
"name": "username",
"email": "mail@domain.com",
"username": "username"
},
"verification": null,
"timestamp": "2021-10-19T15:39:15+02:00",
"added": [],
"removed": [],
"modified": [
"roles/python/defaults/main.yml",
"roles/python/tasks/main.yml"
]
},
example 2:
"commits": [
{
"id": "c3b671330210565926dd4703e21e3c600795ddc2",
"message": "message 1\n",
"url": "https://git.domain.com/username/MyRepo/commit/c3b671330210565926dd4703e21e3c600795ddc2",
"author": {
"name": "username",
"email": "mail@domain.com",
"username": "username"
},
"committer": {
"name": "username",
"email": "mail@domain.com",
"username": "username"
},
"verification": null,
"timestamp": "2021-10-20T16:07:25+02:00",
"added": [],
"removed": [],
"modified": [
"inventory/dev.yml"
]
},
{
"id": "385d7369140ef2b0b544a9ddd2532ef601ea8452",
"message": "message 2\n",
"url": "https://git.domain.com/username/MyRepo/commit/385d7369140ef2b0b544a9ddd2532ef601ea8452",
"author": {
"name": "username",
"email": "mail@domain.com",
"username": "username"
},
"committer": {
"name": "username",
"email": "mail@domain.com",
"username": "username"
},
"verification": null,
"timestamp": "2021-10-20T16:06:04+02:00",
"added": [],
"removed": [],
"modified": [
"group_vars/sbc.yml"
]
}
],
in gitea webview i get 10 digits and in the matrix 8 digits for SHA1
SHA1 in Gitea Web View:
SHA1 in Matrix Message:
the compare
link in the message above links to element web when "compare_url": "",
in json is empty
I'm glad it works now! Regarding your questions:
only one message is sent even if multiple commits are submitted.
This is intentional, to prevent the plugin from generating too many messages, and because Gitea only sends the first and last commits if you push multiple commits at once.
in gitea webview i get 10 digits and in the matrix 8 digits for SHA1
This is because the length of shortened commit hashes is mostly arbitrary. Git itself uses 7 characters, as does GitHub, while Gitea uses 10 characters, and GitLab uses 8.
the
compare
link in the message above links to element web when"compare_url": "",
in json is empty
Good point. I think it's reasonable to remove the link completely if the compare URL is not set.
Fixed in version 1.1.
Hello,
I tried the gitea.ts plugin on my hosted gitea but webhook-gateway shows the error:
2021-10-16 10:00:46.810.000 INFO [plg-gitea] Unknown Gitea action: 'undefined'
gitea config:
last webhook:
do you need more informations to debug?
regards