#650  Can webhook take parameters?
Closed
AlanSun opened 2 years ago

Can webhook take parameters? In other words, what can I get out of a webhook. I would like to receive push messages so that I can tell if a build should be triggered. thanks

Robin Shen commented 2 years ago

The webhook will post json representation of OneDev event to your url. For instance, for code push event, below object will be posted as json:

https://code.onedev.io/projects/160/blob/main/server-core/src/main/java/io/onedev/server/event/RefUpdated.java?position=source-11.14-11.24-1

And for build event, below object will be posted:

https://code.onedev.io/projects/160/blob/main/server-core/src/main/java/io/onedev/server/event/build/BuildEvent.java?position=source-13.14-13.24-1

AlanSun commented 2 years ago

Thanks for your answer. I have tested it and I got this response,

{
  "@class" : "io.onedev.server.event.RefUpdated",
  "user" : null,
  "date" : "2022-03-24T06:07:35.457+00:00",
  "project" : {
    "id" : 94,
    "name" : "tuoyang-backend-hs-pc",
    "description" : "XXXXX",
    "createDate" : "2022-03-20T13:50:37.000+00:00",
    "updateDate" : "2022-03-24T06:05:01.530+00:00",
    "codeManagement" : true,
    "issueManagement" : true,
    "serviceDeskName" : "<$NullServiceDesk$>6725a5ef-5f67-4cc5-a187-5a846302388d",
    "forkedFromId" : null,
    "parentId" : 49,
    "defaultRoleId" : null
  },
  "refName" : "refs/heads/develop",
  "oldCommitId" : "03386d003ab16d9afc498e3b54bad954b7c437a7",
  "newCommitId" : "8ad3ab800e87b4aab87a11c6c0e5e109af1d3a3c"
}

I have some questions,1. Why the user is null, 2. Can I get the latest commit message?

Robin Shen commented 2 years ago

User is null as this type of event is not triggered by user explicitly on web UI. To get the commit message, you may get the commit object via RESTful api:

https://code.onedev.io/help/api/io.onedev.server.rest.RepositoryResource/getCommit

Robin Shen changed state to 'Closed' 2 years ago
Previous Value Current Value
Open
Closed
issue 1 of 1
Type
Question
Priority
Normal
Assignee
Issue Votes (0)
Watchers (4)
Reference
onedev/server#650
Please wait...
Page is in error, reload to recover