-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
46 lines (41 loc) · 1.25 KB
/
Jenkinsfile
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
43
44
45
46
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'docker build -t yamiannephilim/crm:latest .'
}
}
stage('Push') {
steps {
withDockerRegistry(credentialsId: 'docker_hub', url: 'https://index.docker.io/v1/') {
sh 'docker push yamiannephilim/crm'
}
}
}
stage('Clean') {
steps {
script {
def containerId = sh(returnStdout: true, script: 'docker ps -aqf "name=crm"').trim()
if (containerId) {
sh "docker stop $containerId"
sh "docker rm $containerId"
}
}
}
}
stage('Run') {
steps {
sh 'docker container stop crm || echo "this container does not exist"'
sh 'docker network create yan || echo "this network exist"'
sh 'echo y | docker container prune'
sh 'docker run --name crm --network yan --restart=unless-stopped -d yamiannephilim/crm:latest'
}
}
}
post {
always {
cleanWs()
}
}
}