diff --git a/Jenkinsfile b/Jenkinsfile index 286b31a2..b9558893 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,40 +1,24 @@ -node{ - - stage('SCM Checkout'){ - git url: 'https://github.com/MithunTechnologiesDevOps/java-web-app-docker.git',branch: 'master' +pipeline { + agent any + + tools { + maven "Maven-3.9.4" } - - stage(" Maven Clean Package"){ - def mavenHome = tool name: "Maven-3.5.6", type: "maven" - def mavenCMD = "${mavenHome}/bin/mvn" - sh "${mavenCMD} clean package" - - } - - - stage('Build Docker Image'){ - sh 'docker build -t dockerhandson/java-web-app .' - } - - stage('Push Docker Image'){ - withCredentials([string(credentialsId: 'Docker_Hub_Pwd', variable: 'Docker_Hub_Pwd')]) { - sh "docker login -u dockerhandson -p ${Docker_Hub_Pwd}" + + stages { + stage('checkout ') { + steps { + checkout scmGit(branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 'github', url: 'https://github.com/udays111/java-web-app-docker.git']]) + } + + } + stage('build maven ') { + steps { + bat 'mvn clean package' + } } - sh 'docker push dockerhandson/java-web-app' - } - - stage('Run Docker Image In Dev Server'){ - - def dockerRun = ' docker run -d -p 8080:8080 --name java-web-app dockerhandson/java-web-app' - - sshagent(['DOCKER_SERVER']) { - sh 'ssh -o StrictHostKeyChecking=no ubuntu@172.31.20.72 docker stop java-web-app || true' - sh 'ssh ubuntu@172.31.20.72 docker rm java-web-app || true' - sh 'ssh ubuntu@172.31.20.72 docker rmi -f $(docker images -q) || true' - sh "ssh ubuntu@172.31.20.72 ${dockerRun}" - } - + stage('upload artifacts nexus ') { + steps { + } - - } diff --git a/pom.xml b/pom.xml index aa2c2f90..57cd6479 100755 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,9 @@ 5.0.7.RELEASE 4.12 1.2.17 + http://localhost:9000/ + admin + So UTF-8 UTF-8 @@ -98,18 +101,18 @@ - +