forked from akshu20791/php-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
42 lines (40 loc) · 1.55 KB
/
Jenkinsfile
File metadata and controls
42 lines (40 loc) · 1.55 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
31
32
33
34
35
36
37
38
39
40
41
42
pipeline {
agent any
stages{
stage('git cloned'){
steps{
git url:'https://github.com/coshik/php-project/', branch: "master"
}
}
stage('Build docker image'){
steps{
script{
sh 'docker build -t coshik/akshatnewimg6july:v1 .'
sh 'docker images'
}
}
}
stage('Docker login') {
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub-pwd', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
sh "echo $PASS | docker login -u $USER --password-stdin"
sh 'docker push coshik/akshatnewimg6july:v1'
}
}
}
stage('Deploy') {
steps {
script {
def dockerrm = 'sudo docker rm -f My-first-containe2211 || true'
def dockerCmd = 'sudo docker run -itd --name My-first-containe2211 -p 8083:80 coshik/akshatnewimg6july:v1'
sshagent(['sshkeypair']) {
//chnage the private ip in below code
// sh "docker run -itd --name My-first-containe2111 -p 8083:80 akshu20791/2febimg:v1"
sh "ssh -o StrictHostKeyChecking=no ubuntu@172.31.13.249 ${dockerrm}"
sh "ssh -o StrictHostKeyChecking=no ubuntu@172.31.13.249 ${dockerCmd}"
}
}
}
}
}
}