Compare commits
38 Commits
feature/an
...
feature/pa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b739431651 | ||
|
|
b78ed1bcf6 | ||
|
|
00154a9e93 | ||
|
|
df13897a25 | ||
|
|
94db5c3efa | ||
|
|
17291abd2e | ||
|
|
d72a06f005 | ||
|
|
0bd74fa092 | ||
|
|
ac5c2b2106 | ||
|
|
ddce6d49ac | ||
|
|
ba406dd3a9 | ||
|
|
997013ad3f | ||
|
|
9fb3cfce01 | ||
|
|
58f1a5cf3e | ||
|
|
ee4f86c17a | ||
|
|
94609f4347 | ||
|
|
b10e682c11 | ||
|
|
12135903ab | ||
|
|
982fdd2438 | ||
|
|
df3a84426f | ||
|
|
b39bdc130f | ||
|
|
7002a942d3 | ||
|
|
5ee75f88dd | ||
|
|
6a2de89154 | ||
|
|
f6850fa35f | ||
|
|
31ecf84171 | ||
|
|
9b90eae493 | ||
|
|
4056c657d3 | ||
|
|
a5ed743178 | ||
|
|
8afb0e62a3 | ||
|
|
2b4921b5c8 | ||
|
|
4f06b352e5 | ||
|
|
c425e899d4 | ||
|
|
15d6bf124f | ||
|
|
b1440f702b | ||
|
|
90bb5d1ddf | ||
|
|
302893976c | ||
|
|
a4a55e133b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
.idea/*
|
.idea/*
|
||||||
|
target/
|
||||||
|
|||||||
38
Jenkinsfile
vendored
38
Jenkinsfile
vendored
@@ -1,38 +1,26 @@
|
|||||||
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
environment {
|
|
||||||
ANSIBLE_SERVER = "167.99.136.157"
|
|
||||||
}
|
|
||||||
stages {
|
stages {
|
||||||
stage("copy files to ansible server") {
|
stage('test') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo "copying all neccessary files to ansible control node"
|
echo "Testing the application..."
|
||||||
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") {
|
stage('build') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo "calling ansible playbook to configure ec2 instances"
|
echo "Building the application..."
|
||||||
def remote = [:]
|
}
|
||||||
remote.name = "ansible-server"
|
}
|
||||||
remote.host = ANSIBLE_SERVER
|
}
|
||||||
remote.allowAnyHosts = true
|
stage('deploy') {
|
||||||
|
steps {
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'keyfile', usernameVariable: 'user')]){
|
script {
|
||||||
remote.user = user
|
echo "Deploying the application..."
|
||||||
remote.identityFile = keyfile
|
|
||||||
sshScript remote: remote, script: "prepare-ansible-server.sh"
|
|
||||||
sshCommand remote: remote, command: "ansible-playbook my-playbook.yaml"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
plugin: aws_ec2
|
|
||||||
regions:
|
|
||||||
- eu-west-3
|
|
||||||
keyed_groups:
|
|
||||||
- key: tags
|
|
||||||
prefix: tag
|
|
||||||
- key: instance_type
|
|
||||||
prefix: instance_type
|
|
||||||
@@ -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
|
|
||||||
30
pom.xml
30
pom.xml
@@ -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>
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
apt update
|
|
||||||
apt install ansible -y
|
|
||||||
apt install python3-pip -y
|
|
||||||
pip3 install boto3 botocore
|
|
||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user