diff --git a/JENKINSFILE b/JENKINSFILE
new file mode 100644
index 0000000..fa98601
--- /dev/null
+++ b/JENKINSFILE
@@ -0,0 +1,29 @@
+pipeline {
+ agent any
+ tools {
+ maven 'maven'
+ jdk 'java'
+ }
+ stages {
+ stage('Stage-1 : Static Code Quality Using SonarQube') {
+ steps {
+ sh 'mvn sonar:sonar'
+ }
+ }
+ stage('Stage-2 : Build & Push Artifact unto Artifactory manager') {
+ steps {
+ sh 'mvn clean validate compile test install verify package deploy -DskipTests'
+ }
+ }
+ stage('Stage-3 : Deployment - Deploy a Artifact devops-2.0.0-SNAPSHOT.war file to Tomcat Server') {
+ steps {
+ sh 'curl -u admin:redhat@123 -T target/**.war "http://54.146.36.84:8080/manager/text/deploy?path=/devops&update=true"'
+ }
+ }
+ stage('Stage-4 : SmokeTest') {
+ steps {
+ sh 'curl --retry-delay 10 --retry 5 "http://54.146.36.84:8080/devops"'
+ }
+ }
+ }
+}
diff --git a/JenkinsFile b/JenkinsFile
index 33f5c0a..7a5b9b4 100644
--- a/JenkinsFile
+++ b/JenkinsFile
@@ -30,10 +30,10 @@ node {
}
}
stage('Deploy') {
- sh 'curl -u admin:redhat@123 -T target/**.war "http://52.91.244.245:8080/manager/text/deploy?path=/devops&update=true"'
+ sh 'curl -u admin:redhat@123 -T target/**.war "http://13.233.138.132:8060/manager/text/deploy?path=/devops&update=true"'
}
stage("Smoke Test"){
- sh "curl --retry-delay 10 --retry 5 http://52.91.244.245:8080/devops"
+ sh "curl --retry-delay 10 --retry 5 http://13.233.138.132:8060/devops"
}
stage('Artifacts') {
if (isUnix()) {
diff --git a/buildspec.yml b/buildspec.yml
new file mode 100644
index 0000000..82e5fad
--- /dev/null
+++ b/buildspec.yml
@@ -0,0 +1,21 @@
+version: 0.2
+phases:
+ install:
+ runtime-versions:
+ java: corretto11
+ pre_build:
+ commands:
+ - cd src/main/resources/static
+ - cd $CODEBUILD_SRC_DIR
+ #- mvn sonar:sonar
+ - mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=kk-java -DskipTests
+ build:
+ commands:
+ - echo Build started on `date`
+ post_build:
+ commands:
+ - mvn package -DskipTests
+ - echo Build completed on `date`
+artifacts:
+ files:
+ - '**/*'
diff --git a/jenkinsFile b/jenkinsFile
new file mode 100644
index 0000000..49bf421
--- /dev/null
+++ b/jenkinsFile
@@ -0,0 +1,66 @@
+pipeline {
+ agent any
+ tools {
+ maven 'maven'
+ jdk 'java'
+ }
+ stages {
+ /*
+ stage('Stage-0 : Static Code Quality Using SonarQube') {
+ steps {
+ sh 'mvn sonar:sonar'
+ }
+ }
+ stage('Stage-1 : Clean') {
+ steps {
+ sh 'mvn clean'
+ }
+ }
+ stage('Stage-2 : Validate') {
+ steps {
+ sh 'mvn validate'
+ }
+ }
+ stage('Stage-3 : Compile') {
+ steps {
+ sh 'mvn compile'
+ }
+ }
+ stage('Stage-4 : Test') {
+ steps {
+ sh 'mvn test -DskipTests'
+ }
+ }
+ stage('Stage-5 : Install') {
+ steps {
+ sh 'mvn install -DskipTests'
+ }
+ }
+ stage('Stage-6 : Verify') {
+ steps {
+ sh 'mvn verify -DskipTests'
+ }
+ }
+ stage('Stage-7 : Package') {
+ steps {
+ sh 'mvn package -DskipTests'
+ }
+ }
+ stage('Stage-8 : Deploy an Artifact to Artifactory Manager i.e. Nexus/Jfrog') {
+ steps {
+ sh 'mvn deploy -DskipTests'
+ }
+ }
+ stage('Stage-9 : Deployment - Deploy a Artifact devops-2.0.0-SNAPSHOT.war file to Tomcat Server') {
+ steps {
+ sh 'curl -u admin:redhat@123 -T target/**.war "http://54.146.36.84:8080/manager/text/deploy?path=/devops&update=true"'
+ }
+ }
+ */
+ stage('Stage-10 : SmokeTest') {
+ steps {
+ sh 'curl --retry-delay 10 --retry 5 "http://54.146.36.84:8080/devops"'
+ }
+ }
+ }
+}
diff --git a/packer-buildspec.yml b/packer-buildspec.yml
new file mode 100644
index 0000000..ef5349b
--- /dev/null
+++ b/packer-buildspec.yml
@@ -0,0 +1,28 @@
+version: 0.2
+
+phases:
+ pre_build:
+ commands:
+ - echo "Installing HashiCorp Packer..."
+ - curl -qL -o packer.zip https://releases.hashicorp.com/packer/0.12.3/packer_0.12.3_linux_amd64.zip && unzip packer.zip
+ - echo "Installing jq..."
+ - curl -qL -o jq https://stedolan.github.io/jq/download/linux64/jq && chmod +x ./jq
+ - mv packer /usr/local/bin
+ - mv jq /usr/local/bin
+ - pwd
+ - ls -ltr $CODEBUILD_SRC_DIR
+ - cd $CODEBUILD_SRC_DIR/
+ - echo "Validating packer.json"
+ - packer validate packer.json
+ build:
+ commands:
+ - curl -qL -o aws_credentials.json http://169.254.170.2/$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI > aws_credentials.json
+ - aws configure set region $AWS_REGION
+ - aws configure set aws_access_key_id `jq -r '.AccessKeyId' aws_credentials.json`
+ - aws configure set aws_secret_access_key `jq -r '.SecretAccessKey' aws_credentials.json`
+ - aws configure set aws_session_token `jq -r '.Token' aws_credentials.json`
+ - packer build packer.json
+ post_build:
+ commands:
+ - echo "Packer Build Completed on `date`"
+
diff --git a/packer.json b/packer.json
new file mode 100644
index 0000000..507ff48
--- /dev/null
+++ b/packer.json
@@ -0,0 +1,54 @@
+{
+ "variables": {
+ "application_name": "codewithck",
+ "application_version": "1.0.0",
+ "region": "us-east-1",
+ "instance_type": "t2.micro",
+ "source_ami": "ami-083654bd07b5da81d",
+ "ami_shared_accounts": "156779398815"
+ },
+ "builders": [
+ {
+ "name": "{{ user `application_name`}}",
+ "type": "amazon-ebs",
+ "ssh_username": "ubuntu",
+ "force_deregister": "true",
+ "force_delete_snapshot": "true",
+ "associate_public_ip_address": "true",
+ "region": "{{ user `region` }}",
+ "source_ami": "{{ user `source_ami` }}",
+ "instance_type": "{{ user `instance_type` }}",
+ "ami_name": "{{ user `application_name`}}-{{ user `application_version`}}",
+ "ami_users": "{{ user `ami_shared_accounts`}}",
+ "tags": {
+ "Name": "{{ user `application_name` }}",
+ "CreatedBy": "Packer"
+ },
+ "run_tags": {
+ "Name": "{{ user `application_name` }}",
+ "CreatedBy": "Packer"
+ }
+
+ }
+ ],
+ "provisioners": [
+ {
+ "type": "shell",
+ "inline": [
+ "sudo apt update"
+ ]
+ },
+ {
+ "type": "shell",
+ "inline": [
+ "sudo apt install git curl unzip wget -y"
+ ]
+ },
+ {
+ "type": "shell",
+ "inline": [
+ "sudo apt install ansible -y"
+ ]
+ }
+ ]
+}
diff --git a/pom.xml b/pom.xml
index 46fb4a5..e2b0008 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.example
devops
- 1.1.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
war
devops
@@ -21,23 +21,36 @@
UTF-8
UTF-8
1.8
- 2.17
+ 3.0.0-M3
0.7.9
+
+ kk-java
+ https://sonarcloud.io
+
+
-
+
scm:git:git@github.com:keshavkummari/devops.git
scm:git:git@github.com:keshavkummari/devops.git