forked from hub4j/github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHookApp.java
More file actions
51 lines (46 loc) · 1.48 KB
/
Copy pathHookApp.java
File metadata and controls
51 lines (46 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package org.kohsuke;
import org.kohsuke.github.GHEventPayload;
import org.kohsuke.github.GitHub;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.jetty.JettyRunner;
import java.io.IOException;
import java.io.StringReader;
// TODO: Auto-generated Javadoc
/**
* App to test the hook script. You need some internet-facing server that can forward the request to you (typically via
* SSH reverse port forwarding.)
*
* @author Kohsuke Kawaguchi
*/
public class HookApp {
/**
* The main method.
*
* @param args
* the arguments
* @throws Exception
* the exception
*/
public static void main(String[] args) throws Exception {
// GitHub.connect().getMyself().getRepository("sandbox").createWebHook(
// new URL("http://173.203.118.45:18080/"), EnumSet.of(GHEvent.PULL_REQUEST));
JettyRunner jr = new JettyRunner(new HookApp());
jr.addHttpListener(8080);
jr.start();
}
/**
* Do index.
*
* @param req
* the req
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public void doIndex(StaplerRequest req) throws IOException {
String str = req.getParameter("payload");
// System.out.println(str);
GHEventPayload.PullRequest o = GitHub.connect()
.parseEventPayload(new StringReader(str), GHEventPayload.PullRequest.class);
// System.out.println(o);
}
}