Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub notifify 2 #20

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 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
2985945
Testing with Dependcies
jonte450 Feb 12, 2021
b54c4a6
Teststing again!
jonte450 Feb 12, 2021
a1fb8ff
Merge pull request #26 from DD2480-Group-15/issue/22
gzh0528 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
8720c3e
Changing the Code to Match to send a notification to the Webhook
jonte450 Feb 14, 2021
d0c95db
Update pom.xml
jonte450 Feb 14, 2021
185778c
Update ContinuousIntegrationServer.java
jonte450 Feb 14, 2021
addf381
Merge branch 'master' into Github_Notifify_2
jonte450 Feb 14, 2021
44abd74
Update ContinuousIntegrationServer.java
jonte450 Feb 14, 2021
37896c7
Update pom.xml
jonte450 Feb 14, 2021
1f5b49e
Update pom.xml
jonte450 Feb 15, 2021
44da6d2
Update ContinuousIntegrationServer.java
jonte450 Feb 15, 2021
ab54e0b
Update ContinuousIntegrationServer.java
jonte450 Feb 15, 2021
6aad3ef
Update ContinuousIntegrationServer.java
jonte450 Feb 15, 2021
ff25547
Update ContinuousIntegrationServer.java
jonte450 Feb 15, 2021
5315628
Update pom.xml
jonte450 Feb 15, 2021
756b0c5
Update ContinuousIntegrationServer.java
jonte450 Feb 15, 2021
13928d7
Update ContinuousIntegrationServer.java
jonte450 Feb 15, 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
45 changes: 0 additions & 45 deletions ContinuousIntegrationServer.java

This file was deleted.

45 changes: 14 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,35 @@
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. We use Maven for building and managing our project.

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.
We assume here that you have a standard Linux machine (eg with Ubuntu), with Java and Maven installed.

We assume here that you have a standard Linux machine (eg with Ubuntu), with Java installed.

We first checkout this repository:
```
git clone https://github.com/monperrus/smallest-java-ci
cd smallest-java-ci
```
## How to run:
After checking out the repository, build it in the root directory using the following command:

We then download the required dependencies:
```
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
mvn package
```

We compile the skeleton the continuous integration server:
Then start the server on your local machine:
```
javac -cp servlet-api-2.5.jar:jetty-all-$JETTY_VERSION.jar ContinuousIntegrationServer.java
java -jar target/gs-maven-0.1.0.jar
```

We run the server on the machine, and we may make it visible on the Internet thanks to [Ngrok](https://ngrok.com/):
The serverr is visible on the Internet by using [Ngrok](https://ngrok.com/). The public url can be found by running the following commnand in a second terminal window:
```
# 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 +39,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 +48,4 @@ 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.
Binary file added ngrok-stable-linux-amd64.zip
Binary file not shown.
133 changes: 133 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>DD2480-Group-15</groupId>
<artifactId>gs-maven</artifactId>
<packaging>jar</packaging>
<version>0.1.0</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<repositories>
<repository>
<id>java.net2</id>
<name>Repository hosting the jee6 artifacts</name>
<url>https://maven.java.net/content/groups/public/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>


<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>


<!-- https://mvnrepository.com/artifact/org.dmfs/httpurlconnection-executor -->
<dependency>
<groupId>org.dmfs</groupId>
<artifactId>httpurlconnection-executor</artifactId>
<version>0.8</version>
</dependency>



<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-server -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>7.0.2.v20100331</version>
</dependency>


<!-- https://search.maven.org/remotecontent?filepath=org/apache/httpcomponents/httpclient/4.5.9/httpclient-4.5.9.jar -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.9</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.10</version>
</dependency>

<!-- https://search.maven.org/remotecontent?filepath=org/apache/httpcomponents/httpmime/4.5.9/httpmime-4.5.9.jar -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.9</version>
</dependency>

<!-- junit 5, unit test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20201115</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>server.ContinuousIntegrationServer</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</build>
</project>
Loading