forked from srinivas1987devops/myweb
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkins-appnew
46 lines (39 loc) · 1.08 KB
/
Jenkins-appnew
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
pipeline{
agent any
stages{
stage("Git Checkout"){
steps{
git credentialsId: 'javahome2', url: 'https://github.com/srinivas1987devops/myweb.git'
}
stages{
stage('Maven Build'){
steps{
echo "${getLatestCommitId()}"
sh "mvn clean package"
}
}
stage('Docker Build Image'){
steps{
sh "docker build . -t prashanthi2021/qa:${getLatestCommitId()}"
}
}
stage('push to docker hub'){
steps{
withCredentials([string(credentialsId: 'docker-hub', variable: 'dockerPwd')]) {
sh "docker login -u prashanthi2021 -p ${dockerPwd}"
sh "docker push prashanthi2021/qa:${getLatestCommitId()}"
}
}
}
stage('dev-deploy'){
steps{
sshagent(['docker-dev']) {
sh "ssh -o StrictHostKeyChecking=no [email protected] docker rm -f mywebapp"
sh "ssh -o StrictHostKeyChecking=no [email protected] docker run -d -p 8080:8080 --name mywebapp prashanthi2021/qa:${getLatestCommitId()}"
}
}
}
}
}
}
}