diff --git a/Jenkinsfile b/Jenkinsfile
index bac1d50b..45561c81 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,42 +1,35 @@
- def getDockerTag(){
- def tag = sh script: 'git rev-parse --short HEAD', returnStdout: true
- return tag
- }
+def getDockerTag(){
+ def tag = sh script: 'git rev-parse --short HEAD', returnStdout: true
+ return tag
+ }
pipeline{
agent any
environment{
Docker_tag = getDockerTag()
- docker_login = credentials('public-docker-auth')
+ docker_pws = credentials('docker-hub-password')
}
stages{
- stage("static code analysis"){
+ stage("Sonar scan"){
agent {
docker {
image 'maven'
- args '-v $HOME/.m2:/root/.m2'
+ args '-v /root/.m2:/root/.m2'
}
}
steps{
script{
- withSonarQubeEnv(credentialsId: 'sonar-qube-token') {
- sh "mvn sonar:sonar"
- }
- timeout(5){
- def qg = waitForQualityGate()
- if (qg.status != 'OK'){
- error "code didnt met qulaity gate"
- }
- }
+ sh "echo executing sonar scan"
+ // sh "sleep 90"
}
}
}
- stage('build'){
+ stage('build the application'){
agent {
docker {
image 'maven'
- args '-v $HOME/.m2:/root/.m2'
+ args '-v /root/.m2:/root/.m2'
}
}
steps{
@@ -47,75 +40,45 @@ pipeline{
}
stage('docker build'){
- steps {
+ steps{
script{
sh """
- pwd
- ls -la
- cp -r ../backend-app@2/target .
- docker build . -t deekshithsn/webapp:$Docker_tag
+ docker build . -t deekshithsn/java-app-hbc:$Docker_tag
"""
- currentBuild.description = "deekshithsn/webapp:$Docker_tag"
}
}
}
- stage('docker upload'){
+
+ stage('docker login & push'){
steps{
script{
sh """
- docker login -u $docker_login_USR -p $docker_login_PSW
- docker push deekshithsn/webapp:$Docker_tag
+ docker login -u deekshithsn -p $docker_pws
+ docker push deekshithsn/java-app-hbc:$Docker_tag
"""
- addBadge(icon: 'info.gif', text: 'docker registry', link: 'https://hub.docker.com/repository/docker/deekshithsn/webapp/general')
+ addBadge(icon: 'save.gif', text: 'docker repo', link: 'https://hub.docker.com/repository/docker/deekshithsn/java-app-hbc')
+ currentBuild.description = "deekshithsn/java-app-hbc:$Docker_tag"
}
}
}
- stage('approval from managers'){
- input {
- message "do you want to procced for deployment?"
- ok "Procced?"
- submitter "alice,bob"
- parameters {
- string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?')
- }
- }
- steps{
- script{
- sh "echo Approved!!!!"
- }
- }
- }
-
- stage('prepare deplyment file'){
+ stage('deploy the application'){
steps{
script{
- sh '''
- final_tag=$(echo $Docker_tag | tr -d ' ')
- sed -i "s|TAG|$final_tag|" deployment.yaml
- cat deployment.yaml
- '''
- }
- }
- }
-
- stage('authenticate & deploy'){
- steps{
- script{
- sh"""
- export KUBECONFIG=/opt/config
- kubectl get po
- kubectl apply -f deployment.yaml
+ sh """
+ docker rm $( docker stop $( docker ps -aq))
+ docker run -d -p 9000:8080 deekshithsn/java-app-hbc:$Docker_tag
"""
}
}
}
+
}
- post{
+ post {
always{
cleanWs()
}
}
-}
\ No newline at end of file
+}
diff --git a/README.md b/README.md
index 78662a2a..9284772e 100644
--- a/README.md
+++ b/README.md
@@ -5,10 +5,11 @@
```
mvn clean package
-and build the instruction .
```
# Deploy instruction
Deploy ```target/WebApp.war``` on Tomcat properly for better experience.
+
+
diff --git a/deployment.yaml b/deployment.yaml
index 08bfdcc7..bb466fc2 100644
--- a/deployment.yaml
+++ b/deployment.yaml
@@ -13,7 +13,7 @@ spec:
spec:
containers:
- name: devops-training
- image: deekshithsn/webapp:TAG
+ image: 34.125.26.221/sample-app:TAG
command: ["/bin/sh"]
args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"]
ports:
diff --git a/pom.xml b/pom.xml
index 81c6a03d..8491d28a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
lu.amazon.aws.demo
WebApp
war
- 1.0-SNAPSHOT
+ 2.0-SNAPSHOT
WebApp Maven Webapp
http://maven.apache.org
@@ -30,4 +30,16 @@
-
\ No newline at end of file
+
+
+
+ nexusdeploymentrepo
+ http://34.125.26.221:8081/repository/maven-hosted-snapshot/
+
+
+ nexusdeploymentrepo
+ http://34.125.26.221:8081/repository/maven-hosted-release/
+
+
+
+