forked from akshu20791/DevOpsClassCodes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
41 lines (39 loc) · 1.24 KB
/
Jenkinsfile
File metadata and controls
41 lines (39 loc) · 1.24 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
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git url: 'https://github.com/mariantom/DevOpsClassCodes', branch: 'master'
}
}
stage('Build') {
steps {
sh 'mvn clean package'
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -t mariantom/mariaimgaddbook:latest .'
}
}
stage('Docker Login and Push') {
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub-pwd', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
sh 'echo $PASS | docker login -u $USER --password-stdin'
sh 'docker push mariantom/mariaimgaddbook:latest'
}
}
}
stage('Deploy') {
steps {
script {
def dockerCmd = 'docker run -itd --name My-first-containe211 -p 80:8082 mariantom/mariaimgaddbook:latest'
sshagent(['sshkeypair']) {
sh "ssh -o StrictHostKeyChecking=no ubuntu@172-31-22-46 ${dockerCmd}"
}
}
}
}
}
}
}