Account, payment and settings services all togther as mock online service
- Jenkins
- Nginx
- Maven
- Java JDK
- Open a shell terminal and add a new repository key to apt
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
- Now add the jenkins repository to the apt sources
echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
- Update the local database
sudo apt-get update
- And finally install Jenkins
sudo apt-get install jenkins
- Open a browser of your choice and navigate to
http://localhost:8081
- It will ask for a password. You can find it this way
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
After submitting the password you will be prompted to create a new user. We entered admin as user name and password, but this is arbitrary and for testing purposes only!
- Update the local repositories
sudo apt-get update
- Install Nginx
sudo apt-get install nginx
- Enable Nginx in firewall
sudo ufw allow 'Nginx HTTP'
- Restart Nginx
sudo service nginx restart
- Check that it works by navigating to
http://localhost
- Update the local repositories
sudo apt-get update
- Install Maven
sudo apt-get install maven
- Update the local repositories
sudo apt-get update
- Install Java JDK
sudo apt-get install default-jdk
Now let's get started with the nitty gritty!
- Open a browser of your choice and navigate to
http://localhost:8080
-
Login with your user name and password
-
Click on
New Task
(left panel) -
Enter
account-payment-settings
as task name (or anything else you see fit) -
Select
free style
as project type -
Click
OK
-
In the
Source code origin
selectgit
and use the following URL asRepository URL
https://github.com/xApiOrg/account-payment-settings.git
- Scroll down and enable
SCM
, then enter the following command
H/02 * * * *
-
Finally, in the
Run pipeline
add the following steps- Maven tasks
clean verify test install
- Shell script
echo "bash $(pwd)/target/dockerfile/run_linux.sh -k" | at now
- Shell script
echo "bash $(pwd)/target/dockerfile/run_linux.sh -r" | at now
-
Click
Save
The service should start automatically with every build!
The service will listen for requests on the
port 10001
by default
We will redirect all the requests comming towards
http://<host>/ipay
tohttp://localhost:10001/ipay
- Open a shell terminal and go to the available nginx virtual servers folder:
cd /etc/nginx/sites-available
- Edit the default configuration with your preferred text editor:
nano ./default
You should see a location object already present in the file. It serves all requests comming to the root path
/
- Now add a new location object below it:
location /ipay {
include /etc/nginx/proxy_params;
proxy_pass http://localhost:10001/ipay;
}
- Restart the Nginx server:
sudo service nginx restart
- And check with a browser or curl that it is actually working!
http://<public-server-ip>/ipay/account/100
It shoud return:
Metod getAllUserPaymentAccounts( Integer userId) NOT IMPLEMENTED YET Get ALL User's PAYMENT accounts by user Id Parameters, user Id = 113 []
Open a shell terminal and move to the task's directory
cd /var/lib/jenkins/workspace/account-payment-settings
-
Starting the service
- Generate the target folder
mvn generate-resources
- Start the service via the provided shell script
sudo bash ./target/dockerfile/run_linux -r
-
Stopping the service
- Generate the target folder
mvn generate-resources
- Stop the service via the provided shell script
sudo bash ./target/dockerfile/run_linux -k
The
run_linux.sh
is a script writen to help run and kill the service.
To run the service use the parameter
-r
To kill the service use the parameter
-k
Please stop the service by yourself if you started it manually as Jenkins will have no permission to do so!
- Jenkins
- Tomcat
- Maven
- Java JDK
- Open Firewall ports
- Download and install Java JDK
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
- Set environment variables
Create JAVA_HOME environment variable in System variables
Variable name: JAVA_HOME
Variable value: {jdkDirectory} (e.g.: C:\Program Files\Java\jdk1.8.0_144)
Edit Path environment variable in System variables and add %JAVA_HOME% to it
- Download and install Jenkins for Windows
https://jenkins.io/download/
- Open a browser of your choice and navigate to
http://localhost:8080
- It will ask for a password. You can find it here
{jenkinsDirectory}/secrets/initialAdminPassword
- Change Jenkins port to 8081
Open {jenkinsDirectory}\jenkins.xml and change --httpPort=8080 to --httpPort=8081
- Restart Jenkins service
Open Windows services (win + r > services.msc), find Jenkins and restart it. After the restart the new Jenkins URL will be http://localhost:8081
- Download Tomcat
https://tomcat.apache.org/download-80.cgi
- Add and admin user
Open {tomcatDirectory}\tomcat-users.xml and edit it
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="admin" roles="manager-gui, manager-script"/>
<tomcat-users>
- Download Maven
https://maven.apache.org/download.cgi
- Set environment variable
Edit Path environment variable in System variables and add your maven bin directory to it (e.g.: C:\Program Files\apache-maven-3.5.0\bin)
To allow remote access to the applications, tomcat, jenkins... we need to open the port where the application is listening.
- Open a browser of your choice and navigate to
http://localhost:8081
-
Login with your user name and password
-
Click on
New Item
(left panel) -
Enter
account-payment-settings
as task name (or anything else you see fit) -
Select
Freestyle project
as project type -
Click
OK
-
In the
Source Code Management
selectGit
and use the following URL asRepository URL
https://github.com/xApiOrg/account-payment-settings.git
- Scroll down and enable
Poll SCM
, then enter the following command
H/02 * * * *
-
Finally, in the
Build pipeline
add the following steps- Invoke top-level Maven targets
generate-resources
- Execute Windows batch command
.\target\dockerfile\run_windows.bat /QT
-
Click
Save
-
After every Jenkins build the application will be restarted. To try the application navigate to
http://<public-server-ip>:10001/ipay/account/100
The default port is 10001.