-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile_deploy
41 lines (36 loc) · 1.32 KB
/
Jenkinsfile_deploy
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 {label 'webserver'}
stages {
// Removing previous and running versions of the container image
stage('Clean') {
steps {
//sh 'sudo apt-get update -y'
//sh 'sudo apt install docker.io -y && sudo snap install docker'
//echo 'docker installation and update check passed!'
echo 'removing previous container version>>>'
sh 'docker stop sne22-webapp || true'
sh 'docker rm -f sne22-webapp'
sh 'docker rmi rp1sne22/my-webapp:latest'
echo 'old and running version of container was successfully removed!'
}
}
// Pulling the image from the container repository
stage('Pull') {
steps {
echo 'pulling container image from repository>>>'
sh 'docker pull rp1sne22/my-webapp:latest'
echo 'pulling successfull!'
}
}
// Deploying the container to production environment (webserver machine)
stage('Deploy') {
steps {
echo 'attempting container run on port 80>>>'
sh 'docker run -d --name sne22-webapp -p 80:9000 rp1sne22/my-webapp:latest'
echo 'container now running!'
echo 'container was successfully deployed to production!!!'
echo 'you can now access the application on http://10.1.1.40 >>>'
}
}
}
}