-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
68 lines (59 loc) · 1.91 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
pipeline {
agent any
environment {
LOCAL_DOCKER_SERVER = 'unix:///var/run/docker.sock' // Replace with your local Docker server address
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Copy .env file to workspace') {
steps {
withCredentials([file(credentialsId: 'SUPER_DUPER_VPN_ENV_FILE', variable: 'env_file')]) {
script {
def envContent = readFile(env_file)
writeFile file: '.env', text: envContent
}
}
}
}
stage('Copy settings.py to django app') {
steps {
withCredentials([file(credentialsId: 'SUPER_DUPER_VPN_settings_py', variable: 'settings_py')]) {
script {
def appContent = readFile(settings_py)
writeFile file: 'mysite/mysite/settings.py', text: appContent
}
}
}
}
stage('Copy conf.conf to nginx') {
steps {
withCredentials([file(credentialsId: 'SUPER_DUPER_VPN_conf_conf', variable: 'conf_conf')]) {
script {
def appContent = readFile(conf_conf)
writeFile file: 'docker/nginx/conf.conf', text: appContent
}
}
}
}
stage('Run "docker compose up --build -d"') {
steps {
script {
sh 'docker compose down --volumes'
sh 'docker compose up --build -d'
}
}
}
}
post {
success {
echo 'Build and local deployment successful!'
}
failure {
echo 'Build or local deployment failed!'
}
}
}