diff --git a/Jenkinsfile b/Jenkinsfile index 0d1320bb..b6c34792 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,51 +1,79 @@ -currentBuild.displayName = "Devops-Training"+currentBuild.number +currentBuild.displayName = "Final_Demo # "+currentBuild.number -pipeline{ + def getDockerTag(){ + def tag = sh script: 'git rev-parse HEAD', returnStdout: true + return tag + } + - agent { - docker { - image 'maven' - args '-v $HOME/.m2:/root/.m2' +pipeline{ + agent any + environment{ + Docker_tag = getDockerTag() } - } - -stages{ - stage('sonar') - { - steps{ - script{ - withSonarQubeEnv('sonarserver') { - sh "mvn sonar:sonar" - } + + stages{ + + + stage('Quality Gate Statuc Check'){ + + agent { + docker { + image 'maven' + args '-v $HOME/.m2:/root/.m2' } } - } - - - stage('Quality Gate Statuc Check'){ - steps{ - script{ - timeout(time: 1, unit: 'HOURS') { - def qg = waitForQualityGate() - if (qg.status != 'OK') { - error "Pipeline aborted due to quality gate failure: ${qg.status}" + steps{ + script{ + withSonarQubeEnv('sonarserver') { + sh "mvn sonar:sonar" + } + timeout(time: 1, unit: 'HOURS') { + def qg = waitForQualityGate() + if (qg.status != 'OK') { + error "Pipeline aborted due to quality gate failure: ${qg.status}" + } + } + sh "mvn clean install" + } + } } - } - } - } - } - - - - stage('build') - { - steps{ - script{ - sh 'mvn clean deploy' - } - } - } - + + + + stage('build') + { + steps{ + script{ + sh 'cp -r ../devops-training@2/target .' + sh 'docker build . -t deekshithsn/devops-training:$Docker_tag' + withCredentials([string(credentialsId: 'docker_password', variable: 'docker_password')]) { + + sh 'docker login -u deekshithsn -p $docker_password' + sh 'docker push deekshithsn/devops-training:$Docker_tag' + } + } + } + } + + stage('ansible playbook'){ + steps{ + script{ + sh '''final_tag=$(echo $Docker_tag | tr -d ' ') + echo ${final_tag}test + sed -i "s/docker_tag/$final_tag/g" deployment.yaml + ''' + ansiblePlaybook become: true, installation: 'ansible', inventory: 'hosts', playbook: 'ansible.yaml' + } + } + } + + + + } + + + + - } } diff --git a/Jenkisnfile1 b/Jenkisnfile1 deleted file mode 100644 index e159231a..00000000 --- a/Jenkisnfile1 +++ /dev/null @@ -1,83 +0,0 @@ -currentBuild.displayName = "Devops-Training # "+currentBuild.number - - def getDockerTag(){ - def tag = sh script: 'git rev-parse HEAD', returnStdout: true - return tag - } - - -pipeline{ - agent any - environment{ - Docker_tag = getDockerTag() - } - - stages{ - - - stage('Quality Gate Statuc Check'){ - - agent { - docker { - image 'maven' - args '-v $HOME/.m2:/root/.m2' - } - } - steps{ - script{ - withSonarQubeEnv('sonarserver') { - sh "mvn sonar:sonar" - } - timeout(time: 1, unit: 'HOURS') { - def qg = waitForQualityGate() - if (qg.status != 'OK') { - error "Pipeline aborted due to quality gate failure: ${qg.status}" - } - } - sh "mvn clean install" - sh 'pwd' - sh 'ls' - } - } - } - - - - stage('build') - { - steps{ - script{ - sh 'pwd' - sh 'cp -r ../simple_web_application@2/target .' - sh 'ls' - sh 'docker build . -t deekshithsn/devops-training:$Docker_tag' - withCredentials([string(credentialsId: 'docker_password', variable: 'docker_password')]) { - - sh 'docker login -u deekshithsn -p $docker_password' - sh 'docker push deekshithsn/devops-training:$Docker_tag' - } - } - } - } - - stage('ansible playbook'){ - steps{ - script{ - sh '''final_tag=$(echo $Docker_tag | tr -d ' ') - echo ${final_tag}test - sed -i "s/docker_tag/$final_tag/g" deployment.yaml - ''' - ansiblePlaybook become: true, colorized: true, extras: '-vvv' , installation: 'ansible', inventory: 'hosts', playbook: 'ansible.yaml' - } - } - } - - - - } - - - - - -} diff --git a/README.md b/README.md index ef19857b..78662a2a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ -This is a sample Web Application to use during Continuous Integration demos. -#Build Instruction + +# Build Instruction + ``` -mvn3 clean package +mvn clean package +and build the instruction . ``` -#Deploy instruction +# Deploy instruction + +Deploy ```target/WebApp.war``` on Tomcat properly for better experience. -Deploy ```target/WebApp.war``` on Tomcat - diff --git a/deployment.yaml b/deployment.yaml index e091a983..51519809 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -31,6 +31,7 @@ spec: type: NodePort ports: - port: 8080 + nodePort: 31884 protocol: TCP name: http selector: diff --git a/hosts b/hosts index 8fe9ecf1..289312cd 100644 --- a/hosts +++ b/hosts @@ -1,2 +1,2 @@ [test] -104.198.135.119 +Host_ip diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 1fc2cd9c..e0e8bf5c 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -76,11 +76,11 @@
Maven is a build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages.
-