-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
78 lines (73 loc) · 3.23 KB
/
Jenkinsfile
File metadata and controls
78 lines (73 loc) · 3.23 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
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
69
70
71
72
73
74
75
76
77
78
pipeline {
agent {
docker {
image "ghcr.io/opsguild/metaldeploy:latest"
registryUrl "https://ghcr.io"
registryCredentialsId "github-registry-auth"
// Reset entrypoint to allow running shell commands
args '--entrypoint="" -v /var/run/docker.sock:/var/run/docker.sock'
}
}
environment {
GIT_AUTH_METHOD = 'token'
GIT_URL = "${env.GIT_URL}"
GIT_USER = 'hordunlarmy'
USE_SUDO = 'true'
DEPLOYMENT_TYPE= 'baremetal'
ENV_FILES_GENERATE = 'true'
ENV_FILES_STRUCTURE = 'auto'
ENV_FILES_CREATE_ROOT = 'false'
ENV_FILES_FORMAT = 'auto'
}
stages {
// --- STAGING ---
stage('Deploy Staging') {
when { branch 'staging' }
steps {
withCredentials([
// Staging Secrets (Use unique IDs!)
string(credentialsId: 'git-token', variable: 'GIT_TOKEN'),
string(credentialsId: 'staging-remote-pass', variable: 'REMOTE_PASSWORD'),
string(credentialsId: 'staging-remote-host', variable: 'REMOTE_HOST'),
file(credentialsId: 'staging-app-env', variable: 'ENV_APP'),
file(credentialsId: 'staging-atlas-env', variable: 'ENV_ATLAS'),
file(credentialsId: 'staging-database-env', variable: 'ENV_DATABASE'),
file(credentialsId: 'staging-minio-env', variable: 'ENV_MINIO'),
file(credentialsId: 'staging-redis-env', variable: 'ENV_REDIS')
]) {
script {
def cmd = 'export env=staging && make up && make migrate'
withEnv(["ENVIRONMENT=staging", "DEPLOY_COMMAND=${cmd}"]) {
// Use absolute path to the tool inside the container
sh "python /app/main.py"
}
}
}
}
}
// --- PRODUCTION ---
stage('Deploy Production') {
when { branch 'main' }
steps {
withCredentials([
// Production Secrets
string(credentialsId: 'git-token', variable: 'GIT_TOKEN'),
string(credentialsId: 'prod-remote-pass', variable: 'REMOTE_PASSWORD'),
string(credentialsId: 'prod-remote-host', variable: 'REMOTE_HOST'),
file(credentialsId: 'prod-app-env', variable: 'ENV_APP'),
file(credentialsId: 'prod-atlas-env', variable: 'ENV_ATLAS'),
file(credentialsId: 'prod-database-env', variable: 'ENV_DATABASE'),
file(credentialsId: 'prod-minio-env', variable: 'ENV_MINIO'),
file(credentialsId: 'prod-redis-env', variable: 'ENV_REDIS')
]) {
script {
def cmd = 'export env=prod && make up && make migrate'
withEnv(["ENVIRONMENT=prod", "DEPLOY_COMMAND=${cmd}"]) {
sh "python /app/main.py"
}
}
}
}
}
}
}