-
Notifications
You must be signed in to change notification settings - Fork 210
/
FinalJenkinsfile
35 lines (33 loc) · 1.05 KB
/
FinalJenkinsfile
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
pipeline {
agent any
stages{
stage('git cloned'){
steps{
git url:'https://github.com/akshu20791/php-project/', branch: "master"
}
}
stage('Build docker image'){
steps{
script{
sh 'docker build -t akshu20791/myprojectnew: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 akshu20791/myprojectnew:v1'
}
}
}
stage('Deploy') {
steps {
script{
sh 'sudo docker run -itd --name My-project-con -p 8089:80 akshu20791/myprojectnew:v1'
}
}
}
}
}