forked from ramnadh333/sample-app-1
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJenkinsfile1
More file actions
executable file
·30 lines (28 loc) · 1.03 KB
/
Jenkinsfile1
File metadata and controls
executable file
·30 lines (28 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
node {
stage('Source Code From GIT') {
git credentialsId: 'GitHub', url: 'https://github.com/devops-mptech/sample-app'
}
stage('Mven Build') {
def Maven_Home = tool name: 'maven-3.3.9', type: 'maven'
def Maven_Bin = "${Maven_Home}/bin/mvn"
sh "${Maven_Bin} clean package"
}
stage('Create Docker Image') {
sh "docker build -t sureshkanna/sampleapp:0.0.9 ."
}
stage('Push To Docker Hub') {
withCredentials([string(credentialsId: 'DockerHubPassword', variable: 'DockerHubPassword')]) {
sh "docker login -u sureshkanna -p ${DockerHubPassword}"
}
sh "docker push sureshkanna/sampleapp:0.0.9"
}
stage('Deploy To Dev') {
def Docker_Command = "docker run -d -p 8080:8080 --name suresh sureshkanna/sampleapp:0.0.9"
def docker = "docker rm -f suresh"
sshagent(['Dockerhub']) {
sh "ssh -o StrictHostKeyChecking=no ec2-user@52.90.83.111 ${docker}"
sh "ssh -o StrictHostKeyChecking=no ec2-user@52.90.83.111 ${Docker_Command}"
sh "ssh -o StrictHostKeyChecking=no ec2-user@52.90.83.111 ${Docker_Command}"
}
}
}