-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 05cfb81
Showing
11 changed files
with
354 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | ||
|
||
name: Java CI with Maven | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
cache: maven | ||
- name: Build with Maven | ||
run: mvn -B package --file pom.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM tomcat:8 | ||
COPY target/java-example.war /usr/local/tomcat/ | ||
EXPOSE 8080 | ||
CMD ["catalina.sh", "run"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
node('') { | ||
stage ('checkout code'){ | ||
checkout scm | ||
} | ||
|
||
stage ('Build'){ | ||
sh "mvn clean install -Dmaven.test.skip=true" | ||
} | ||
|
||
stage ('Test Cases Execution'){ | ||
sh "mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Pcoverage-per-test" | ||
} | ||
|
||
stage ('Sonar Analysis'){ | ||
//sh 'mvn sonar:sonar -Dsonar.host.url=http://35.153.67.119:9000 -Dsonar.login=77467cfd2653653ad3b35463fbfdb09285f08be5' | ||
} | ||
|
||
stage ('Archive Artifacts'){ | ||
archiveArtifacts artifacts: 'target/*.war' | ||
} | ||
|
||
stage ('Deployment'){ | ||
//deploy adapters: [tomcat9(credentialsId: 'TomcatCreds', path: '', url: 'http://3.84.47.228:8080/')], contextPath: 'counterwebapp', war: 'target/*.war' | ||
} | ||
|
||
stage ('Notification'){ | ||
emailext ( | ||
subject: "Job Completed", | ||
body: "Jenkins Pipeline Job for Maven Build got completed !!!", | ||
to: "[email protected]" | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
HelloWorld Servlet example with corresponding Dockerfile | ||
|
||
Use Maven Build first to create war file in Target folder. | ||
|
||
mvn clean package | ||
|
||
Artifact will be created in target folder. | ||
|
||
docker build -t mavenbuild . | ||
|
||
Once this is done u will be see image using docker image | ||
|
||
Use below command to run the container | ||
|
||
docker run -d -p 8080:8080 --name dockercontainer mavenbuild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- hosts: webservers | ||
vars: | ||
- warName: java-example.war | ||
- warRemotePath: /opt/apache-tomcat-8.5.73/webapps/ | ||
|
||
tasks: | ||
- name: Copy WAR to Remote server | ||
copy: src=target/{{ warName }} dest={{ warRemotePath }}/{{ warName }} owner=tomcat group=tomcat | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<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 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.java.example</groupId> | ||
<artifactId>java-example</artifactId> | ||
<packaging>war</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<url>http://maven.apache.org</url> | ||
<dependencies> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
<version>2.5</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<finalName>java-example</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.0.2</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<profiles> | ||
<profile> | ||
<id>coverage-per-test</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<!-- Minimal supported version is 2.4 --> | ||
<version>2.13</version> | ||
<configuration> | ||
<properties> | ||
<property> | ||
<name>listener</name> | ||
<value>org.sonar.java.jacoco.JUnitListener</value> | ||
</property> | ||
</properties> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.sonarsource.java</groupId> | ||
<artifactId>sonar-jacoco-listeners</artifactId> | ||
<version>3.8</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.geekcap.vmturbo; | ||
|
||
import javax.servlet.*; | ||
import javax.servlet.http.*; | ||
import java.io.*; | ||
|
||
public class HelloWorldServlet extends HttpServlet | ||
{ | ||
@Override | ||
public void service( HttpServletRequest req, HttpServletResponse res ) throws IOException { | ||
PrintWriter out = res.getWriter(); | ||
out.println( "Hello, World!" ); | ||
out.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.geekcap.vmturbo; | ||
|
||
public class Thing { | ||
private int n = 0; | ||
|
||
public int getN() { | ||
return n; | ||
} | ||
|
||
public void setN(int n) { | ||
this.n = n; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE web-app PUBLIC | ||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | ||
"http://java.sun.com/dtd/web-app_2_3.dtd" > | ||
|
||
<web-app> | ||
<display-name>Hello World Servlet</display-name> | ||
|
||
<servlet> | ||
<servlet-name>hello</servlet-name> | ||
<servlet-class>com.geekcap.vmturbo.HelloWorldServlet</servlet-class> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>hello</servlet-name> | ||
<url-pattern>/hello</url-pattern> | ||
</servlet-mapping> | ||
|
||
</web-app> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Jenkins Deployment Training</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> | ||
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-theme-teal.css"> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto"> | ||
<link rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" | ||
> | ||
<link rel="stylesheet" type="text/css" href="./style.css" media="screen"/> | ||
</head> | ||
<body> | ||
<nav class="w3-sidebar w3-bar-block w3-collapse w3-animate-left w3-card" style="z-index:3;width:250px;" id="mySidebar"> | ||
<a class="w3-bar-item w3-button w3-border-bottom w3-large" href="#"><img src="https://www.w3schools.com/images/w3schools.png" style="width:80%;"></a> | ||
<a class="w3-bar-item w3-button w3-hide-large w3-large" href="javascript:void(0)" onclick="w3_close()">Close <i class="fa fa-remove"></i></a> | ||
<a class="w3-bar-item w3-button w3-teal" href="#">Home</a> | ||
<a class="w3-bar-item w3-button" href="#">Link 1</a> | ||
<a class="w3-bar-item w3-button" href="#">Link 2</a> | ||
<a class="w3-bar-item w3-button" href="#">Link 3</a> | ||
<a class="w3-bar-item w3-button" href="#">Link 4</a> | ||
<a class="w3-bar-item w3-button" href="#">Link 5</a> | ||
<div> | ||
<a class="w3-bar-item w3-button" onclick="myAccordion('demo')" href="javascript:void(0)">Dropdown <i class="fa fa-caret-down"></i></a> | ||
<div id="demo" class="w3-hide"> | ||
<a class="w3-bar-item w3-button" href="#">Link</a> | ||
<a class="w3-bar-item w3-button" href="#">Link</a> | ||
<a class="w3-bar-item w3-button" href="#">Link</a> | ||
</div> | ||
</div> | ||
</nav> | ||
<div class="w3-overlay w3-hide-large w3-animate-opacity" onclick="w3_close()" style="cursor:pointer" id="myOverlay"></div> | ||
<div class="w3-main" style="margin-left:250px;"> | ||
<div id="myTop" class="w3-container w3-top w3-theme w3-large"> | ||
<p><i class="fa fa-bars w3-button w3-teal w3-hide-large w3-xlarge" onclick="w3_open()"></i> | ||
<span id="myIntro" class="w3-hide">W3.CSS: Introduction</span></p> | ||
</div> | ||
<header class="w3-container w3-theme" style="padding:64px 32px"> | ||
<h1 class="w3-xxxlarge">W3.CSS</h1> | ||
</header> | ||
<div class="w3-container" style="padding:32px"> | ||
<h2>What is W3.CSS?</h2> | ||
<p>W3.CSS is a modern CSS framework with built-in responsiveness:</p> | ||
<ul class="w3-leftbar w3-theme-border" style="list-style:none"> | ||
<li>Smaller and faster than other CSS frameworks.</li> | ||
<li>Easier to learn, and easier to use than other CSS frameworks.</li> | ||
<li>Uses standard CSS only (No jQuery or JavaScript library).</li> | ||
<li>Speeds up mobile HTML apps.</li> | ||
<li>Provides CSS equality for all devices. PC, laptop, tablet, and mobile:</li> | ||
</ul> | ||
<br> | ||
<img src="./img_responsive.png" style="width:100%" alt="Responsive"> | ||
<hr> | ||
<h2>W3.CSS is Free</h2> | ||
<p>W3.CSS is free to use. No license is necessary.</p> | ||
<hr> | ||
<h2>Easy to Use</h2> | ||
<div class="w3-container w3-sand w3-leftbar"> | ||
<p><i>Make it as simple as possible, but not simpler.</i> | ||
<br>Albert Einstein | ||
</p> | ||
</div> | ||
<hr> | ||
<h2>W3.CSS Web Site Templates</h2> | ||
<p>We have created some responsive W3CSS templates for you to use.</p> | ||
<p>You are free to modify, save, share, use or do whatever you want with them:</p> | ||
<div class="w3-panel w3-light-grey w3-padding-16 w3-card"> | ||
<h3 class="w3-center">Band Template</h3> | ||
<div class="w3-content" style="max-width:800px"> | ||
<a | ||
href="https://www.w3schools.com/w3css/tryw3css_templates_band.htm" | ||
target="_blank" title="Band Demo"> | ||
<img | ||
src="./img_temp_band.jpg" | ||
style="width:98%;margin:20px 0" | ||
alt="Band Template"> | ||
</a><br> | ||
<div class="w3-row"> | ||
<div class="w3-col m6"> | ||
<a | ||
href="https://www.w3schools.com/w3css/tryw3css_templates_band.htm" | ||
target="_blank" | ||
class="w3-button w3-padding-large w3-dark-grey" | ||
style="width:98.5%">Demo | ||
</a> | ||
</div> | ||
<div class="w3-col m6"> | ||
<a | ||
href="https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_templates_band&stacked=h" | ||
target="_blank" | ||
class="w3-button w3-padding-large w3-dark-grey" | ||
style="width:98.5%">More Templates » | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="w3-container w3-padding-16 w3-card" style="background-color:#eee"> | ||
<h3 class="w3-center">Blog Template</h3> | ||
<div class="w3-content" style="max-width:800px"> | ||
<img | ||
src="./img_temp_blog.jpg" | ||
style="width:98%;margin:20px 0" | ||
alt="Blog Template"><br> | ||
<div class="w3-row"> | ||
<div class="w3-col m6"> | ||
<a | ||
href="https://www.w3schools.com/w3css/tryw3css_templates_blog.htm" | ||
target="_blank" | ||
class="w3-button w3-padding-large w3-dark-grey" | ||
style="width:98.5%">Demo | ||
</a> | ||
</div> | ||
<div class="w3-col m6"> | ||
<a | ||
href="https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_templates_blog&stacked=h" | ||
target="_blank" | ||
class="w3-button w3-padding-large w3-dark-grey" | ||
style="width:98.5%">More Templates » | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<footer class="w3-container w3-theme" style="padding:32px"> | ||
<p>Footer information goes here</p> | ||
</footer> | ||
</div> | ||
<script type="text/javascript" src="./arquivojs.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.geekcap.vmturbo; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Created by shaines on 7/24/16. | ||
*/ | ||
public class ThingTest { | ||
|
||
@Test | ||
public void testN() { | ||
Thing t = new Thing(); | ||
t.setN(5); | ||
Assert.assertEquals("N should be 5", 5, t.getN()); | ||
} | ||
} |