-
Notifications
You must be signed in to change notification settings - Fork 23
/
ContinuousIntegrationServer.java
45 lines (38 loc) · 1.4 KB
/
ContinuousIntegrationServer.java
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
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
/**
Skeleton of a ContinuousIntegrationServer which acts as webhook
See the Jetty documentation for API documentation of those classes.
*/
public class ContinuousIntegrationServer extends AbstractHandler
{
public void handle(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html;charset=utf-8");
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
System.out.println(target);
// here you do all the continuous integration tasks
// for example
// 1st clone your repository
// 2nd compile the code
response.getWriter().println("CI job done");
}
// used to start the CI server in command line
public static void main(String[] args) throws Exception
{
Server server = new Server(8080);
server.setHandler(new ContinuousIntegrationServer());
server.start();
server.join();
}
}