-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
67 lines (62 loc) · 1.96 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
pipeline {
agent any
tools {
nodejs '20.17.0'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Write .env File') {
steps {
script {
withCredentials([
string(credentialsId: '60850337-55a7-4857-a176-1f434d4cf8b5', variable: 'POSTGRES_PASSWORD'),
string(credentialsId: 'fc04f487-0afc-45fe-bfa2-b9348a6bf813', variable: 'JWT_SECRET')
]) {
def envContent = """
POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
DATABASE_URL=postgresql://orientation:${POSTGRES_PASSWORD}@localhost:5432
JWT_SECRET=${JWT_SECRET}
URL=https://orientation.cssu.ca
"""
writeFile file: '.env', text: envContent.trim()
}
}
}
}
stage('Build') {
steps {
sh 'docker compose build'
}
}
stage('Deploy and Migrate') {
steps {
script {
sh 'docker compose up -d --wait'
sh 'prisma generate'
sh 'prisma migrate deploy'
sh 'prisma db seed'
}
}
}
}
post {
success {
publishChecks name: 'Jenkins CI',
title: 'Build Succeeded',
summary: 'The build completed successfully',
text: 'All stages completed without any issues',
conclusion: 'SUCCESS'
}
failure {
publishChecks name: 'Jenkins CI',
title: 'Build Failed',
summary: 'The build failed',
text: 'One or more stages failed. Docker compose was shut down.',
conclusion: 'FAILURE'
}
}
}