diff --git a/README.md b/README.md
index 9cec002..4cc2a7c 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
# docker-Java-kubernetes-project
-Deploying Java Applications with Docker and Kubernetes
+Deploying Java Application with Docker and Kubernetes
Credit: https://github.com/danielbryantuk/oreilly-docker-java-shopping/
diff --git a/inventory/k8-inventory b/inventory/k8-inventory
new file mode 100644
index 0000000..f619db1
--- /dev/null
+++ b/inventory/k8-inventory
@@ -0,0 +1,5 @@
+[MAVEN]
+192.168.0.112 ansible_user=jits ansible_ssh_pass=redhat
+
+[localhost]
+192.168.0.112
\ No newline at end of file
diff --git a/jenkinsfiles/deployk8 b/jenkinsfiles/deployk8
new file mode 100644
index 0000000..051a029
--- /dev/null
+++ b/jenkinsfiles/deployk8
@@ -0,0 +1,40 @@
+properties([
+ parameters([
+ string(defaultValue: 'dev-uat', name: 'BRANCH'),
+ string(defaultValue: 'master', name: 'comp'),
+ string(defaultValue: 'master', name: 'mvn'),
+ string(defaultValue: 'service', name: 'action')
+ ])
+])
+
+node {
+ cleanWs()
+
+ echo "The workspace directory is ${env.WORKSPACE}"
+
+ stage('Git Checkout') {
+ git branch: "${params.BRANCH}", credentialsId: 'myjenkins', url: 'git@github.com:pjitss/docker-Java-kubernetes-project.git'
+ }
+
+
+
+ stage('SonarQube Analysis') {
+ withCredentials([string(credentialsId: 'mysonar2', variable: 'SONAR_TOKEN')]) {
+ withSonarQubeEnv('mysonar') {
+ sh """
+ mvn clean verify sonar:sonar \
+ -Dsonar.projectKey=mysonar2 \
+ -Dsonar.host.url=http://192.168.0.190:9000 \
+ -Dsonar.login=$SONAR_TOKEN
+ """
+ }
+ }
+ }
+
+ stage('Execute Ansible Playbooks on Kubernetes Master') {
+ ansiblePlaybook(
+ playbook: "playbooks/k8deploy-main.yml",
+ extras: "-i inventory/k8-inventory -e target_host=${comp} -e mvn=${mvn}"
+ )
+ }
+}
\ No newline at end of file
diff --git a/others/settings.xml_file b/others/settings.xml_file
new file mode 100644
index 0000000..6c4584e
--- /dev/null
+++ b/others/settings.xml_file
@@ -0,0 +1,190 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ nexus-releases
+ jitsnexus
+ {9VYKv8N4arIHArUuHxu7j/gKBkgIyAt663MEHi5EDPY=}
+
+
+ nexus-snapshots
+ jitsnexus
+ {9VYKv8N4arIHArUuHxu7j/gKBkgIyAt663MEHi5EDPY=}
+
+
+
+
+
+
+
+ maven-default-http-blocker
+ external:http:*
+ Pseudo repository to mirror external repositories initially using HTTP.
+ http://0.0.0.0/
+ true
+
+
+
+
+
+
+
+
+
+
+ nexus
+
+
+ nexus-releases
+ http://192.168.0.190:8081/repository/maven-releases/
+ true
+ false
+
+
+ nexus-snapshots
+ http://192.168.0.190:8081/repository/maven-snapshots/
+ true
+ false
+
+
+
+
+ nexus
+ http://102.168.0.190:8081/repository/maven-public/
+ true
+ true
+
+
+
+
+
+
+
+
+ alwaysActiveProfile
+ anotherAlwaysActiveProfile
+
+
+ nexus
+
+
diff --git a/playbooks/k8deploy-main.yml b/playbooks/k8deploy-main.yml
new file mode 100644
index 0000000..c8aba9f
--- /dev/null
+++ b/playbooks/k8deploy-main.yml
@@ -0,0 +1,72 @@
+- hosts: "{{ target_host }}"
+ gather_facts: false
+ #become: yes
+ #become_method: sudo
+ #become_user: jits
+ tasks:
+
+ - name: Ensure jenkins owns the workspace directory
+ file:
+ path: "/var/lib/jenkins/workspace/cicd-k8/shopfrontss"
+ state: directory
+ owner: jenkins
+ group: jenkins
+ recurse: yes
+ become: yes
+ when: mvn == "prm"
+
+ - name: execute mvn command for shopfront
+ shell: /opt/maven/apache-maven-3.8.8/bin/mvn clean deploy
+ #register: shop_output
+ args:
+ chdir: "{{ lookup('env', 'WORKSPACE') }}/shopfront"
+ when: mvn == "shop" or mvn == "allapps"
+ become: yes
+
+ - name: execute mvn command for productcatalogue
+ command: /opt/maven/apache-maven-3.8.8/bin/mvn clean deploy
+ #register: product_output
+ args:
+ chdir: "{{ lookup('env', 'WORKSPACE') }}/productcatalogue"
+ when: mvn == "product" or mvn == "allapps"
+ become: yes
+
+ - name: execute mvn command for stockmanager
+ command: /opt/maven/apache-maven-3.8.8/bin/mvn clean deploy
+ #register: stock_output
+ args:
+ chdir: "{{ lookup('env', 'WORKSPACE') }}/stockmanager"
+ when: mvn == "stock" or mvn == "allapps"
+ become: yes
+
+ #- name: Print all mvn outputs
+ # debug:
+ # msg: |
+ # Shopfront output: {{ shop_output.stdout | default('Not executed') }}
+ # Product Catalogue output: {{ product_output.stdout | default('Not executed') }}
+ # Stock Manager output: {{ stock_output.stdout | default('Not executed') }}
+
+ - name: Build and Push Docker image for shopfront
+ docker_image:
+ name: "jitss/shopfront:1.1"
+ build:
+ path: "{{ lookup('env', 'WORKSPACE') }}/shopfront"
+ push: yes
+ when: mvn == "docker"
+
+ - name: Build and Push Docker image for productcatalogue
+ docker_image:
+ name: "jitss/productcatalogue:1.1"
+ build:
+ path: "{{ lookup('env', 'WORKSPACE') }}/productcatalogue"
+ push: yes
+ when: mvn == "docker"
+
+ - name: Build and Push Docker image for stockmanager
+ docker_image:
+ name: "jitss/productcatalogue:1.1"
+ build:
+ path: "{{ lookup('env', 'WORKSPACE') }}/stockmanager"
+ push: yes
+ when: mvn == "docker"
+
diff --git a/productcatalogue/pom.xml b/productcatalogue/pom.xml
index 14b6206..8e9f359 100644
--- a/productcatalogue/pom.xml
+++ b/productcatalogue/pom.xml
@@ -25,9 +25,9 @@
guice
${guice.version}
+
-
@@ -76,4 +76,17 @@
-
+
+
+
+
+ nexus-releases
+ http://192.168.0.190:8081/repository/maven-releases/
+
+
+ nexus-snapshots
+ http://192.168.0.190:8081/repository/maven-snapshots/
+
+
+
+
\ No newline at end of file
diff --git a/productcatalogue/pom.xml_bkp b/productcatalogue/pom.xml_bkp
new file mode 100644
index 0000000..14b6206
--- /dev/null
+++ b/productcatalogue/pom.xml_bkp
@@ -0,0 +1,79 @@
+
+
+ 4.0.0
+
+ uk.co.danielbryant.djshopping
+ productcatalogue
+ 0.0.1-SNAPSHOT
+
+
+ UTF-8
+ 1.3.27
+ 4.2.3
+
+
+
+
+ io.dropwizard
+ dropwizard-core
+ ${dropwizard.version}
+
+
+ com.google.inject
+ guice
+ ${guice.version}
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.8
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 1.6
+
+ true
+
+
+ *:*
+
+ META-INF/*.SF
+ META-INF/*.DSA
+ META-INF/*.RSA
+
+
+
+
+
+
+ package
+
+ shade
+
+
+
+
+
+ uk.co.danielbryant.djshopping.productcatalogue.ProductServiceApplication
+
+
+
+
+
+
+
+
+
diff --git a/shopfront/pom.xml b/shopfront/pom.xml
index 1535a9a..c3db46a 100644
--- a/shopfront/pom.xml
+++ b/shopfront/pom.xml
@@ -73,4 +73,17 @@
+
+
+
+
+ nexus-releases
+ http://192.168.0.190:8081/repository/maven-releases/
+
+
+ nexus-snapshots
+ http://192.168.0.190:8081/repository/maven-snapshots/
+
+
+
diff --git a/stockmanager/pom.xml b/stockmanager/pom.xml
index ca2beaf..42945cb 100644
--- a/stockmanager/pom.xml
+++ b/stockmanager/pom.xml
@@ -82,4 +82,17 @@
+
+
+
+
+ nexus-releases
+ http://192.168.0.190:8081/repository/maven-releases/
+
+
+ nexus-snapshots
+ http://192.168.0.190:8081/repository/maven-snapshots/
+
+
+