Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pom.xml #46

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 20 additions & 36 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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 [email protected] docker stop java-web-app || true'
sh 'ssh [email protected] docker rm java-web-app || true'
sh 'ssh [email protected] docker rmi -f $(docker images -q) || true'
sh "ssh [email protected] ${dockerRun}"
}

stage('upload artifacts nexus ') {
steps {

}


}
15 changes: 9 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<spring.version>5.0.7.RELEASE</spring.version>
<junit.version>4.12</junit.version>
<log4j.version>1.2.17</log4j.version>
<sonar.host.url>http://localhost:9000/</sonar.host.url>
<sonar.login>admin</sonar.login>
<sonar.password>So</sonar.password>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Expand Down Expand Up @@ -98,18 +101,18 @@

</dependencies>

<!-- <distributionManagement>
<distributionManagement>
<repository>
<id>nexus</id>
<name>Mithun Technologies Releases Nexus Repository</name>
<url>http://13.235.8.113:8081/repository/flipkart-release/</url>
<name>java application </name>
<url>http://localhost:8081/repository/java-nexus/</url>
</repository>
<snapshotRepository>
<id>nexus</id>
<name>Mithun Technologies Snapshot Nexus Repository </name>
<url>http://13.235.8.113:8081/repository/flipkart-snapshot/</url>
<name>java application </name>
<url>http://localhost:8081/repository/java-nexus/</url>
</snapshotRepository>
</distributionManagement> -->
</distributionManagement>

<build>
<plugins>
Expand Down