30 Commits

Author SHA1 Message Date
Nana Janashia
39cd2b4274 Delete script.groovy 2020-11-06 12:28:42 +00:00
Nana Janashia
97716be9e5 Delete Jenkinsfile 2020-11-06 12:28:25 +00:00
Nana Janashia
e7c31d0701 Update Jenkinsfile 2020-11-06 11:15:15 +00:00
Nana Janashia
2702970ffc Update Jenkinsfile 2020-11-06 10:53:22 +00:00
Nana Janashia
3610ff3f17 Update Jenkinsfile 2020-11-06 10:52:18 +00:00
Nana Janashia
51a1618bf9 Update Jenkinsfile 2020-11-06 10:51:55 +00:00
Nana Janashia
2f4822a421 Update Jenkinsfile 2020-11-06 10:50:51 +00:00
Nana Janashia
57b5004ec8 Update Jenkinsfile 2020-11-06 10:39:13 +00:00
Nana Janashia
cdacbeeec4 Update Jenkinsfile 2020-11-06 09:14:56 +00:00
Nana Janashia
1228821c74 Update Jenkinsfile 2020-11-06 09:10:05 +00:00
Nana Janashia
650570153a Update Jenkinsfile 2020-11-06 08:33:33 +00:00
Nana Janashia
e5f3bc546b Update Jenkinsfile 2020-11-06 08:28:39 +00:00
Nana Janashia
99d992ee76 Add new file 2020-11-05 17:47:49 +00:00
Nana Janashia
273c10f041 Update Jenkinsfile 2020-11-05 17:47:23 +00:00
Nana Janashia
e0be3b5f9d Update Jenkinsfile 2020-11-05 17:23:39 +00:00
Nana Janashia
c4cba3ddc6 Update Jenkinsfile-basic 2020-11-05 14:31:01 +00:00
Nana Janashia
8fb1d04fa8 Update Jenkinsfile 2020-11-05 14:30:29 +00:00
Nana Janashia
48aa2427b3 Add Jenkinsfile 2020-11-05 14:04:42 +00:00
Nana Janashia
ed870a0c6b Delete Jenkinsfile 2020-11-05 13:43:16 +00:00
Nana
28932727d1 add dockerfile 2020-11-01 14:00:03 +01:00
Nana
2ef267a3fb fix test 2020-11-01 13:04:44 +01:00
Nana Janashia
05f3e19201 Update freestyle-build.sh 2020-11-01 12:02:04 +00:00
Nana Janashia
5d8d48709e Update src/test/java/AppTest.java 2020-11-01 12:00:55 +00:00
Nana Janashia
fa5460fa44 Update freestyle-build.sh 2020-11-01 11:54:56 +00:00
Nana Janashia
ae9b87113d Update freestyle-build.sh 2020-11-01 11:34:40 +00:00
Nana Janashia
86350ca4e1 Update Jenkinsfile 2020-10-31 15:30:40 +00:00
Nana Janashia
51edfc3d66 Update Jenkinsfile 2020-10-31 15:29:57 +00:00
Nana Janashia
c8da404d8b Update Jenkinsfile 2020-10-31 15:29:01 +00:00
Nana Janashia
18a24797ed Add new file 2020-10-31 15:27:17 +00:00
Nana Janashia
710e1151f8 Add new file 2020-10-31 13:40:38 +00:00
20 changed files with 108 additions and 141 deletions

8
Dockerfile Normal file
View File

@@ -0,0 +1,8 @@
FROM openjdk:8-jre-alpine
EXPOSE 8080
COPY ./target/java-maven-app-1.0-SNAPSHOT.jar /usr/app/
WORKDIR /usr/app
ENTRYPOINT ["java", "-jar", "java-maven-app-1.0-SNAPSHOT.jar"]

40
Jenkinsfile vendored
View File

@@ -1,40 +0,0 @@
pipeline {
agent any
environment {
ANSIBLE_SERVER = "167.99.136.157"
}
stages {
stage("copy files to ansible server") {
steps {
script {
echo "copying all neccessary files to ansible control node"
sshagent(['ansible-server-key']) {
sh "scp -o StrictHostKeyChecking=no ansible/* root@${ANSIBLE_SERVER}:/root"
withCredentials([sshUserPrivateKey(credentialsId: 'ec2-server-key', keyFileVariable: 'keyfile', usernameVariable: 'user')]) {
sh 'scp $keyfile root@$ANSIBLE_SERVER:/root/ssh-key.pem'
}
}
}
}
}
stage("execute ansible playbook") {
steps {
script {
echo "calling ansible playbook to configure ec2 instances"
def remote = [:]
remote.name = "ansible-server"
remote.host = ANSIBLE_SERVER
remote.allowAnyHosts = true
withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'keyfile', usernameVariable: 'user')]){
remote.user = user
remote.identityFile = keyfile
sshScript remote: remote, script: "prepare-ansible-server.sh"
sshCommand remote: remote, command: "ansible-playbook my-playbook.yaml"
}
}
}
}
}
}

View File

@@ -1,9 +0,0 @@
[defaults]
host_key_checking = False
inventory = inventory_aws_ec2.yaml
interpreter_python = /usr/bin/python3
enable_plugins = aws_ec2
remote_user = ec2-user
private_key_file = ~/ssh-key.pem

View File

@@ -1,9 +0,0 @@
---
plugin: aws_ec2
regions:
- eu-west-3
keyed_groups:
- key: tags
prefix: tag
- key: instance_type
prefix: instance_type

View File

@@ -1,29 +0,0 @@
---
- name: Install python3, docker, docker-compose
hosts: all
become: yes
gather_facts: False
tasks:
- name: Install python3 and docker
vars:
ansible_python_interpreter: /usr/bin/python
yum:
name:
- python3
- docker
update_cache: yes
state: present
- name: Install Docker-compose
get_url:
url: https://github.com/docker/compose/releases/download/1.27.4/docker-compose-Linux-{{lookup('pipe', 'uname -m')}}
dest: /usr/local/bin/docker-compose
mode: +x
- name: Start docker daemon
systemd:
name: docker
state: started
- name: Install docker python module
pip:
name:
- docker
- docker-compose

2
freestyle-build.sh Normal file
View File

@@ -0,0 +1,2 @@
# npm --version
# docker --version

30
pom.xml
View File

@@ -6,35 +6,7 @@
<groupId>com.example</groupId> <groupId>com.example</groupId>
<artifactId>java-maven-app</artifactId> <artifactId>java-maven-app</artifactId>
<version>1.1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.5.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- to handle any Java version mismatch, add the following configuration for maven-compiler-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies> <dependencies>
<dependency> <dependency>

View File

@@ -1,6 +0,0 @@
#!/usr/bin/env bash
apt update
apt install ansible -y
apt install python3-pip -y
pip3 install boto3 botocore

View File

@@ -1,19 +0,0 @@
def buildJar() {
echo "building the application..."
sh 'mvn package'
}
def buildImage() {
echo "building the docker image..."
withCredentials([usernamePassword(credentialsId: 'docker-hub-repo', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
sh 'docker build -t nanajanashia/demo-app:jma-2.0 .'
sh "echo $PASS | docker login -u $USER --password-stdin"
sh 'docker push nanajanashia/demo-app:jma-2.0'
}
}
def deployApp() {
echo 'deploying the application...'
}
return this

View File

@@ -0,0 +1,16 @@
import com.example.Application;
import org.junit.Test;
import static org.junit.Assert.*;
public class AppTest {
@Test
public void testApp() {
Application myApp = new Application();
String result = myApp.getStatus();
assertEquals("OK", result);
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,5 @@
#Generated by Maven
#Thu Oct 29 12:55:55 CET 2020
version=1.0-SNAPSHOT
groupId=com.example
artifactId=java-maven-app

View File

@@ -0,0 +1 @@
com/example/Application.class

View File

@@ -0,0 +1 @@
/Users/nanajanashia/Demo-projects/Bootcamp/java-maven-app/src/main/java/com/example/Application.java

View File

@@ -0,0 +1,4 @@
-------------------------------------------------------------------------------
Test set: AppTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.061 sec

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite tests="1" failures="0" name="AppTest" time="0.003" errors="0" skipped="0">
<properties>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="sun.boot.library.path" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib"/>
<property name="java.vm.version" value="25.202-b08"/>
<property name="user.country.format" value="AT"/>
<property name="gopherProxySet" value="false"/>
<property name="java.vm.vendor" value="Oracle Corporation"/>
<property name="maven.multiModuleProjectDirectory" value="/Users/nanajanashia/Demo-projects/Bootcamp/java-maven-app"/>
<property name="java.vendor.url" value="http://java.oracle.com/"/>
<property name="path.separator" value=":"/>
<property name="guice.disable.misplaced.annotation.check" value="true"/>
<property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
<property name="file.encoding.pkg" value="sun.io"/>
<property name="user.country" value="GB"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="sun.os.patch.level" value="unknown"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="user.dir" value="/Users/nanajanashia/Demo-projects/Bootcamp/java-maven-app"/>
<property name="java.runtime.version" value="1.8.0_202-b08"/>
<property name="java.awt.graphicsenv" value="sun.awt.CGraphicsEnvironment"/>
<property name="java.endorsed.dirs" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/endorsed"/>
<property name="os.arch" value="x86_64"/>
<property name="java.io.tmpdir" value="/var/folders/y3/bvgmrxg950x0f1z4zt3pby3c0000gn/T/"/>
<property name="line.separator" value="
"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="os.name" value="Mac OS X"/>
<property name="classworlds.conf" value="/usr/local/Cellar/maven/3.6.0/libexec/bin/m2.conf"/>
<property name="sun.jnu.encoding" value="UTF-8"/>
<property name="java.library.path" value="/Users/nanajanashia/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:."/>
<property name="maven.conf" value="/usr/local/Cellar/maven/3.6.0/libexec/conf"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="java.class.version" value="52.0"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="os.version" value="10.14.6"/>
<property name="library.jansi.path" value="/usr/local/Cellar/maven/3.6.0/libexec/lib/jansi-native"/>
<property name="http.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="user.home" value="/Users/nanajanashia"/>
<property name="user.timezone" value="Europe/Vienna"/>
<property name="java.awt.printerjob" value="sun.lwawt.macosx.CPrinterJob"/>
<property name="java.specification.version" value="1.8"/>
<property name="file.encoding" value="UTF-8"/>
<property name="user.name" value="nanajanashia"/>
<property name="java.class.path" value="/usr/local/Cellar/maven/3.6.0/libexec/boot/plexus-classworlds-2.5.2.jar"/>
<property name="java.vm.specification.version" value="1.8"/>
<property name="sun.arch.data.model" value="64"/>
<property name="java.home" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre"/>
<property name="sun.java.command" value="org.codehaus.plexus.classworlds.launcher.Launcher test"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="user.language" value="en"/>
<property name="awt.toolkit" value="sun.lwawt.macosx.LWCToolkit"/>
<property name="java.vm.info" value="mixed mode"/>
<property name="java.version" value="1.8.0_202"/>
<property name="java.ext.dirs" value="/Users/nanajanashia/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java"/>
<property name="sun.boot.class.path" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/classes"/>
<property name="java.vendor" value="Oracle Corporation"/>
<property name="maven.home" value="/usr/local/Cellar/maven/3.6.0/libexec"/>
<property name="file.separator" value="/"/>
<property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/>
<property name="sun.cpu.endian" value="little"/>
<property name="sun.io.unicode.encoding" value="UnicodeBig"/>
<property name="socksNonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="sun.cpu.isalist" value=""/>
</properties>
<testcase classname="AppTest" name="testApp" time="0.003"/>
</testsuite>

Binary file not shown.