A Java calculator web app, build by Maven, CI/CD by Jenkins.
image from https://jenkins.io/doc/book/pipeline/
mvn clean package
mvn jetty:run
By default, the jetty port is 9999, so you should visit following urls in browser:
http://localhost:9999/calculator/api/calculator/ping
http://localhost:9999/calculator/api/calculator/add?x=8&y=26
http://localhost:9999/calculator/api/calculator/sub?x=12&y=8
http://localhost:9999/calculator/api/calculator/mul?x=11&y=8
http://localhost:9999/calculator/api/calculator/div?x=12&y=12
To run in a different port
mvn jetty:run -Djetty.port=<your port>
set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n
mvn jetty:run
mvn clean test
mvn clean integration-test
You need change pom.xml, point to your Tomcat 8x.
mvn cargo:run
You need install Jmeter first, and make sure your Tomcat 8x is runing.
mvn clean verify
To run in command line mode with parameters
./bin/jmeter.sh -n -t ./tests/CalculatorTestPlan.jmx -Jusers=20 -Jloop=2 -l ./results/calculator_`date +'%y%m%d%H%M%S'`.cs
mvn site
Project name: MyJavaMavenCalculateWebApp
Execute every mvn goal one by one defined in Build Section Step: "Invoke top-level Maven targets"
Project name: MyJavaMavenCalculateWebApp-AzureAppService-FTP
Project name: MyJavaMavenCalculateWebApp-AzureAppService
Project name: MyJavaMavenCalculateWebApp-Pipeline
Execute the Jenkins Pipeline Script File: Jenkinsfile
-
Build a docker image using
Dockerfile
:docker build -t calculator .
-
Run docker image locally
docker run --rm -p 8080:8080 calculator
-
Then you can access the web app at http://localhost:8080/api/calculator/ping in browser
-
Stop container
docker ps -a docker stop <Container-ID>
-
Push your local image to your docker hub repositories
docker login -u <Your-Docker-ID> -p <Your-Docker-Password> docker tag calculator <Your-Docker-ID>/calculator docker push <Your-Docker-ID>/calculator
- Create a Web App in Linux on Azure
- Save the changes and you'll be able to access the web app in a few seconds.
- Create a Container Registry on Azure
- Push your local image to ACR:
docker login <Your-ACR-Login-Server> -u <Your-ACR-Username> -p <Your-ACR-Password> docker tag calculator <Your-ACR-Login-Server>/calculator docker push <Your-ACR-Login-Server>/calculator
- Create a Web App in Linux on Azure
- In Docker Container settings of Web App, fill in image name, server URL, username and password of your ACR.
- Save the changes and you'll be able to access the web app in a few seconds.