Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
4be9f21
Fixed typo in README
SQUEEEE Feb 9, 2021
cd8e957
Update README.md
gzh0528 Feb 9, 2021
457813b
Setup travis
Feb 9, 2021
a0d60b0
Update README.md
gzh0528 Feb 9, 2021
7459b35
Add maven build
CSCphilip Feb 9, 2021
8309dc3
Modify .travis file
CSCphilip Feb 9, 2021
e552e75
Update README.md
gzh0528 Feb 9, 2021
5cd30c6
Merge pull request #6 from DD2480-Group-15/travis-maven
gzh0528 Feb 9, 2021
a101aee
Update README.md
gzh0528 Feb 9, 2021
5a08b4f
Made it so that the ci-server can extract urls from webhooks and clon…
Wizkas0 Feb 9, 2021
06a24b4
Update README.md
gzh0528 Feb 10, 2021
85652b5
Fixed a bug with the ci-server 8#
Wizkas0 Feb 10, 2021
f48972d
Add rules in .gitignore related to Maven and some other.
CSCphilip Feb 10, 2021
1c14a43
Add .idea rule in .gitignore and remove .idea folder
CSCphilip Feb 10, 2021
a8de5f1
Add test skeleton
CSCphilip Feb 10, 2021
37d418c
this adds documentation to ci-server #9
Wizkas0 Feb 10, 2021
a382fc9
Add dummy test that uses server object #7
CSCphilip Feb 10, 2021
1e26f20
Update README with instructions #9
SQUEEEE Feb 10, 2021
150271a
Merge pull request #10 from DD2480-Group-15/testing
SQUEEEE Feb 10, 2021
e46aa33
Fixes ci-server to only handle push-events #11
Wizkas0 Feb 10, 2021
e8cdd83
Started code skeleton #12
SQUEEEE Feb 10, 2021
adf8fc9
A
jonte450 Feb 10, 2021
7f2fb6a
Merge branch 'master' of https://github.com/DD2480-Group-15/ci-server
jonte450 Feb 10, 2021
a7d74af
Fixes #14 by adding test.json to server-folder. Adds a function that …
Wizkas0 Feb 10, 2021
63ff905
Merge pull request #15 from DD2480-Group-15/issue/14
CSCphilip Feb 10, 2021
a2d9710
Removed unnecessary imports
SQUEEEE Feb 10, 2021
e317267
merge
jonte450 Feb 10, 2021
cdbc39f
Wrapped request handling in if statement so it only runs if github push
SQUEEEE Feb 10, 2021
2eff502
Merged with master to keep up to date
SQUEEEE Feb 10, 2021
8ff8620
Starting to break down the JSON parsing
SQUEEEE Feb 10, 2021
cd584a9
Trying to get the JSON parser to work
SQUEEEE Feb 10, 2021
18cb987
Cleaning up code
SQUEEEE Feb 11, 2021
9a5b9a1
Small update of README
SQUEEEE Feb 11, 2021
bbe6aea
Working on #12 dividing into smaller functions
SQUEEEE Feb 11, 2021
5da3d52
Merge branch 'master' of https://github.com/DD2480-Group-15/ci-server
jonte450 Feb 11, 2021
955eb55
Merge pull request #19 from DD2480-Group-15/issue/12
gzh0528 Feb 11, 2021
ca02a5a
Merge branch 'master' of https://github.com/DD2480-Group-15/ci-server
jonte450 Feb 11, 2021
1ccf2e0
Modified JSON related things, issue #21
CSCphilip Feb 12, 2021
1fe1caf
Merge pull request #25 from DD2480-Group-15/issue/21
SQUEEEE Feb 12, 2021
28462bc
Updated webhook instructions #9
SQUEEEE Feb 12, 2021
6e02d25
test
jonte450 Feb 12, 2021
720611d
Removing some line
jonte450 Feb 12, 2021
8f39a8a
Add clone repo functionality #22
CSCphilip Feb 12, 2021
a1fb8ff
Merge pull request #26 from DD2480-Group-15/issue/22
gzh0528 Feb 13, 2021
23441f2
Merge branch 'master' of https://github.com/DD2480-Group-15/ci-server
jonte450 Feb 13, 2021
0a018c7
Fixes #23 by completing getRepoUrl
Wizkas0 Feb 13, 2021
7c069a7
Clone a repo will now work when ./cloned-repo already exist #27.
CSCphilip Feb 13, 2021
51d1e3e
Merge pull request #31 from DD2480-Group-15/issue/27
gzh0528 Feb 13, 2021
3fe5a2f
Get BuildandTest functional. Done with issue #4
Feb 13, 2021
5fd8bc3
Get BuildandTest functional and Fixed bugs for cloneRepo. Done with i…
Feb 13, 2021
a29906c
Merge branch 'master' into issue/4
gzh0528 Feb 13, 2021
90a0776
Adding some tests
jonte450 Feb 14, 2021
79f4870
Merge pull request #32 from DD2480-Group-15/issue/4
CSCphilip Feb 15, 2021
bb0f8c1
Clean up in the code
CSCphilip Feb 15, 2021
0b81c47
Update ContinuousIntegrationServer.java
jonte450 Feb 15, 2021
d8000cf
Update TestServer.java
jonte450 Feb 15, 2021
0ab3ed7
Update TestServer.java
jonte450 Feb 15, 2021
9813c20
Update TestServer.java
jonte450 Feb 15, 2021
711fd08
Add javadoc to some methods #9
CSCphilip Feb 15, 2021
127dc77
Update TestServer.java
jonte450 Feb 15, 2021
d29c45c
Update TestServer.java
jonte450 Feb 15, 2021
7e720b9
Update TestServer.java
jonte450 Feb 15, 2021
d256145
Update TestServer.java
jonte450 Feb 15, 2021
2923ccb
Update TestServer.java
jonte450 Feb 15, 2021
0f37699
Merge branch 'master' into Create_Tests
jonte450 Feb 15, 2021
9178a7d
Update ContinuousIntegrationServer.java
jonte450 Feb 15, 2021
ed1f087
Update ContinuousIntegrationServer.java
jonte450 Feb 15, 2021
bf25150
Fixes #3 by completing set_commit_status()
Wizkas0 Feb 15, 2021
82dffcb
Merge pull request #35 from DD2480-Group-15/issue/3
gzh0528 Feb 16, 2021
3dd50aa
Fixes #36 by implementing a getStatusUrl-fuction
Wizkas0 Feb 16, 2021
0e66a71
Merge pull request #37 from DD2480-Group-15/issue/36
gzh0528 Feb 16, 2021
95556fa
Merge remote-tracking branch 'origin/Create_Tests'
Wizkas0 Feb 16, 2021
d2ef956
Merge pull request #34 from DD2480-Group-15/Create_Tests
Wizkas0 Feb 16, 2021
ebd0a23
Done with issue #38
Feb 16, 2021
21ac74d
Merge remote-tracking branch 'origin/master'
Wizkas0 Feb 16, 2021
84f419b
Update README with ngrok instructions #17
SQUEEEE Feb 16, 2021
d7945fa
Split the token. Done with issue #41
Feb 16, 2021
0b8ff4c
Added statement of contribution and project info #40
SQUEEEE Feb 16, 2021
102a939
Update README.md
jonte450 Feb 16, 2021
32649ff
Update README.md
jonte450 Feb 16, 2021
bac1305
Update README.md
jonte450 Feb 16, 2021
a3eb9e3
Merge pull request #42 from DD2480-Group-15/issue/41
SQUEEEE Feb 16, 2021
30e2c28
Merge remote-tracking branch 'origin/master'
Wizkas0 Feb 16, 2021
b18a304
Add set_commit_status when build fails #43
CSCphilip Feb 17, 2021
c309ba1
You can call functions from CIsever in TestServer now. Done with issu…
Feb 17, 2021
6c695c7
Merge pull request #45 from DD2480-Group-15/issue/44
jonte450 Feb 17, 2021
847531f
Merge remote-tracking branch 'origin/master'
Wizkas0 Feb 17, 2021
0486b6a
Started on the build history feature #46
CSCphilip Feb 17, 2021
0529d02
fixes #47 creates test for getJSON #7
Wizkas0 Feb 17, 2021
a960a61
Merge pull request #48 from DD2480-Group-15/issue/7
SQUEEEE Feb 17, 2021
8060b61
Update README.md
jonte450 Feb 17, 2021
1e695ad
Added helper function in TestServer for getting a JSONObject from a file
SQUEEEE Feb 17, 2021
4369355
Changed test_getJSON to use the help_getJSON function
SQUEEEE Feb 17, 2021
21c2158
Finished test_getStatusUrl and removed an uneccesary print
SQUEEEE Feb 17, 2021
8cdbe2d
Added test for getRepoURL
SQUEEEE Feb 17, 2021
9a7616f
Clean up of test code
SQUEEEE Feb 17, 2021
e5751a1
Merge pull request #50 from DD2480-Group-15/issue/7
CSCphilip Feb 17, 2021
4dc8c95
Added history html.Done with issue #46
Feb 17, 2021
829d8ba
Merge remote-tracking branch 'origin/issue/46' into issue/46
Feb 17, 2021
a26da06
Add first version of browsable javadoc
CSCphilip Feb 17, 2021
e555896
Update README
gzh0528 Feb 17, 2021
9cd1a83
Removed code that generated a test file #53
SQUEEEE Feb 17, 2021
f4e69d4
Merge pull request #51 from DD2480-Group-15/issue/46
CSCphilip Feb 17, 2021
a79dbbe
Updated javadoc comments #9
SQUEEEE Feb 17, 2021
8e48bdd
Updated documentation with javadocs #9
SQUEEEE Feb 17, 2021
ea008c2
Deleted unnecessary files #53
SQUEEEE Feb 17, 2021
0d2c773
Removed dummyTest function #53
SQUEEEE Feb 17, 2021
b58d920
Fixed typo in README #40
SQUEEEE Feb 17, 2021
641ae04
Add version 2 of browsable javadoc #9
CSCphilip Feb 17, 2021
2fc73d0
Created a folder to store build history and removed useless html. Don…
Feb 17, 2021
eba89b0
Merge pull request #55 from DD2480-Group-15/issue/54
SQUEEEE Feb 17, 2021
53fb002
Add version 3 of browsable javadoc #9
CSCphilip Feb 17, 2021
41a6512
Merge branch 'master' of github.com:DD2480-Group-15/ci-server
CSCphilip Feb 17, 2021
041d672
Updata Readme #40
gzh0528 Feb 17, 2021
42601ba
Trigger failed test second try
SQUEEEE Feb 17, 2021
b4af203
Fixed bugs in CI server. Done with issue #56
Feb 17, 2021
4c7a836
Merge branch 'master' of github.com:DD2480-Group-15/ci-server #56
Feb 17, 2021
b551dfd
Merge cleaned up. Done with issue #56
Feb 17, 2021
ef7f3f8
Update README #40
gzh0528 Feb 17, 2021
921bc61
Updated README with History instructions
SQUEEEE Feb 17, 2021
32c36a6
Update README statement of contribution #40
SQUEEEE Feb 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
*.class
.vscode/*
.classpath
.project
.settings/*
dependency-reduced-pom.xml
target/*
.idea/*
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: java
54 changes: 54 additions & 0 deletions Build_History/History.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!doctype html>
<html>
<head>
<title>My build history</title>
</head>
<body>
<a href="#">These are the URLs<br></a>
<a onclick="CreateHistory(0)" href="#">https://api.github.com/repos/gzh0528/ci-server/statuses/cd578476aaae3f8d5c23d6ab2e87ef93601ef6e7<br></a>
<a onclick="CreateHistory(1)" href="#">https://api.github.com/repos/gzh0528/ci-server/statuses/ee22fad706519f89b6bce12be35ff04c0f859be9<br><a onclick="CreateHistory(2)" href="#">https://api.github.com/repos/DD2480-Group-15/ci-server/statuses/641ae048a4c1c83096d1031c3037ebf015a3b591<br></a><br></a>
<br>
<br>
<br>
<p id="Show"></p>
<script>
function CreateHistory(id) {
fetch('data.json')
.then(response => response.json())
.then(data => {
var history=data;
var col = [];
for (var i = 0; i < history.length; i++) {
for (var key in history[i]) {
if (col.indexOf(key) === -1) {
col.push(key);
}
}
}
var table = document.createElement("table");
var tr = table.insertRow(-1);
for (var i = 0; i < col.length; i++) {
var th = document.createElement("th");
th.innerHTML = col[i];
tr.appendChild(th);
}
for (var i = 0; i < history.length; i++) {
tr = table.insertRow(-1);
for (var j = 0; j < col.length; j++) {
var tabCell = tr.insertCell(-1);
if (i==id)
{
tabCell.innerHTML = history[i][col[j]];
}
}
}
var divContainer = document.getElementById("Show");
divContainer.innerHTML = "";
divContainer.appendChild(table);

});
return false;
}
</script>
</body>
</html>
1 change: 1 addition & 0 deletions Build_History/data.json

Large diffs are not rendered by default.

45 changes: 0 additions & 45 deletions ContinuousIntegrationServer.java

This file was deleted.

63 changes: 34 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,54 @@
The smallest Java Continuous Integration server for Github
A small Java Continuous Integration server.
===========================================================
This is a simple server for Continuous Integration development. It is meant to be called as webhook by Github. The HTTP part of it is based on Jetty. Maven is used to build and test, and notifications to the repository are sent through the GitHub status API. The server keeps a history of the past builds and log files attached to them.

Here is a tiny CI server skeleton implemented in Java for educational purposes. It is meant to be called as webhook by Github. The HTTP part of it is based on Jetty.
## Contributions
**Philip Andersson (CSCphilp):** Maven handling, JSON handling, bug fixes, docs

We assume here that you have a standard Linux machine (eg with Ubuntu), with Java installed.
**Zehua Guo (gzh0528):** Cloning, building and testing the repository, Build History

**Jonatan Yao Håkansson (jonte450):** Testing,Notifify function helped together with Kalle

**Elisabet Lövkvist (SQUEEEE):** Documentation, code skeleton for server functions, tests

**Kalle Meurman (Wizkas0):** Cloning the repo, sending notification to GitHub

## How to run:
We assume here that you have a standard Linux machine (eg with Ubuntu), with Java and Maven installed. After checking out the repository, build it in the root directory using the following command:

We first checkout this repository:
```
git clone https://github.com/monperrus/smallest-java-ci
cd smallest-java-ci
mvn package
```

We then download the required dependencies:
Then start the server on your local machine:
```
JETTY_VERSION=7.0.2.v20100331
wget -U none https://repo1.maven.org/maven2/org/eclipse/jetty/aggregate/jetty-all/$JETTY_VERSION/jetty-all-$JETTY_VERSION.jar
wget -U none https://repo1.maven.org/maven2/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar
#For linux users:
curl -LO --tlsv1 https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
unzip ngrok-stable-linux-amd64.zip
#For Mac user:
curl -LO --tlsv1 https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-386.zip
unzip ngrok-stable-darwin-386.zip
java -jar target/gs-maven-0.1.0.jar
```
## Using Ngrok to connect the server to GitHub
The server can be made visible on the Internet by using [Ngrok](https://ngrok.com/).

### Download Ngrok
First you need to download it:

We compile the skeleton the continuous integration server:
```
javac -cp servlet-api-2.5.jar:jetty-all-$JETTY_VERSION.jar ContinuousIntegrationServer.java
curl -LO --tlsv1 https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
unzip ngrok-stable-linux-amd64.zip
```
### Run Ngrok and connect to GitHub

We run the server on the machine, and we may make it visible on the Internet thanks to [Ngrok](https://ngrok.com/):
The public url can be found by running the following commnand in a separate terminal window to the one running the server (in the same folder as Ngrok was downloaded):
```
# open a first terminal window
JETTY_VERSION=7.0.2.v20100331
java -cp .:servlet-api-2.5.jar:jetty-all-$JETTY_VERSION.jar ContinuousIntegrationServer

# open a second terminal window
# this gives you the public URL of your CI server to set in Github
# copy-paste the forwarding URL "Forwarding http://8929b010.ngrok.io -> localhost:8080"
# note that this url is short-lived, and is reset everytime you run ngrok
./ngrok http 8080

```

We configure our Github repository:
Copy the url looking like [number sequence].ngrok.io, then go to the GitHub repository you want to the server to monitor.

* go to `Settings >> Webhooks`, click on `Add webhook`.
* paste the forwarding URL (eg `http://8929b010.ngrok.io`) in field `Payload URL`) and send click on `Add webhook`. In the simplest setting, nothing more is required.
* paste the forwarding URL (eg `http://8929b010.ngrok.io`) in field `Payload URL`) and send click on `Add webhook`.
* **Set the content type to application/json**

We test that everything works:

Expand All @@ -56,7 +58,7 @@ We test that everything works:
* observe the result, in two ways:
* locally: in the console of your first terminal window, observe the requested URL printed on the console
* on github: go to `Settings >> Webhooks` in your repo, click on your newly created webhook, scroll down to "Recent Deliveries", click on the last delivery and the on the `Response tab`, you'll see the output of your server `CI job done`
* on ngrok: raise the terminal window with Ngrok, and you'll also the see URLs requested by Github
* on ngrok: raise the terminal window with Ngrok, and you'll also the see URLs requested by Github.

We shutdown everything:

Expand All @@ -65,4 +67,7 @@ We shutdown everything:
* delete the webhook in the webhook configuration page.

Notes:
* by default, Github delivers a `push` JSON payloard, documented here: <https://developer.github.com/v3/activity/events/types/#pushevent>, this information can be used to get interesting information about the commit that has just been pushed.
* by default, Github delivers a `push` JSON payload, documented here: <https://developer.github.com/v3/activity/events/types/#pushevent>, this information can be used to get interesting information about the commit that has just been pushed.

### View history of past builds
The history data is stored in data.json. To see the history, you can click the html file called History.html in the Build_History folder. The html page contains a list of URLs. By clicking each of them, you will see the log of that build.
101 changes: 101 additions & 0 deletions docs/allclasses-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (15) on Wed Feb 17 21:24:04 CET 2021 -->
<title>All Classes (gs-maven 0.1.0 API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="dc.created" content="2021-02-17">
<meta name="description" content="class index">
<meta name="generator" content="javadoc/AllClassesIndexWriter">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="script-dir/jquery-ui.min.css" title="Style">
<link rel="stylesheet" type="text/css" href="jquery-ui.overrides.css" title="Style">
<script type="text/javascript" src="script.js"></script>
<script type="text/javascript" src="script-dir/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="script-dir/jquery-ui.min.js"></script>
</head>
<body class="all-classes-index-page">
<script type="text/javascript">var pathtoroot = "./";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="flex-box">
<header role="banner" class="flex-header">
<nav role="navigation">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="top-nav" id="navbar.top">
<div class="skip-nav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<ul id="navbar.top.firstrow" class="nav-list" title="Navigation">
<li><a href="server/package-summary.html">Package</a></li>
<li>Class</li>
<li>Use</li>
<li><a href="server/package-tree.html">Tree</a></li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="sub-nav">
<div class="nav-list-search"><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</div>
</div>
<!-- ========= END OF TOP NAVBAR ========= -->
<span class="skip-nav" id="skip.navbar.top">
<!-- -->
</span></nav>
</header>
<div class="flex-content">
<main role="main">
<div class="header">
<h1 title="All&amp;nbsp;Classes" class="title">All&nbsp;Classes</h1>
</div>
<div class="type-summary" id="all-classes-table">
<table class="summary-table">
<caption><span>Class Summary</span></caption>
<thead>
<tr>
<th class="col-first" scope="col">Class</th>
<th class="col-last" scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr class="alt-color" id="i0">
<td class="col-first"><a href="server/ContinuousIntegrationServer.html" title="class in server">ContinuousIntegrationServer</a>&lt;<a href="server/ContinuousIntegrationServer.html" title="type parameter in ContinuousIntegrationServer">BASE64Encoder</a>,&#8203;<a href="server/ContinuousIntegrationServer.html" title="type parameter in ContinuousIntegrationServer">BASE64Decoder</a>&gt;</td>
<th class="col-last" scope="row">
<div class="block">Skeleton of a ContinuousIntegrationServer which acts as webhook
See the Jetty documentation for API documentation of those classes.</div>
</th>
</tr>
</tbody>
</table>
</div>
</main>
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottom-nav" id="navbar.bottom">
<div class="skip-nav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<ul id="navbar.bottom.firstrow" class="nav-list" title="Navigation">
<li><a href="server/package-summary.html">Package</a></li>
<li>Class</li>
<li>Use</li>
<li><a href="server/package-tree.html">Tree</a></li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<span class="skip-nav" id="skip.navbar.bottom">
<!-- -->
</span></nav>
<p class="legal-copy"><small>Copyright &#169; 2021. All rights reserved.</small></p>
</footer>
</div>
</div>
</body>
</html>
Loading