-
Notifications
You must be signed in to change notification settings - Fork 8.6k
/
2022-docker-ci-cd
38 lines (36 loc) · 1.18 KB
/
2022-docker-ci-cd
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
pipeline{
agent any
stages{
stage("Git Checkout"){
steps{
git url:"https://github.com/javahometech/my-app"
}
}
stage("Maven Package"){
steps{
sh "mvn clean package"
}
}
stage("Docker Build"){
steps{
sh "docker build -t kammana/hariapp:${env.BUILD_NUMBER} ."
}
}
stage("DockerHub Push"){
steps{
withCredentials([usernamePassword(credentialsId: 'dockerhub', passwordVariable: 'pwd', usernameVariable: 'user')]) {
sh "docker login -u ${user} -p ${pwd}"
sh "docker push kammana/hariapp:${env.BUILD_NUMBER}"
}
}
}
stage("Docker Deploy Dev"){
steps{
sshagent(['docker-dev-ssh']) {
sh "ssh -o StrictHostKeyChecking=no [email protected] docker rm -f hariapp"
sh "ssh [email protected] docker run -d -p 8080:8080 --name hariapp kammana/hariapp:${env.BUILD_NUMBER}"
}
}
}
}
}