-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
95 lines (84 loc) · 2.92 KB
/
Jenkinsfile
File metadata and controls
95 lines (84 loc) · 2.92 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git branch: 'main',
credentialsId: 'gpt404',
url: 'https://github.com/AlvaroLucioRibeiro/GPT-Not-Found-Backend'
}
}
stage('Set up Python Environment') {
steps {
script {
sh '''#!/bin/bash
python3 -m venv venv
. venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
'''
}
}
}
stage('Build with PyInstaller') {
steps {
script {
sh '''#!/bin/bash
. venv/bin/activate # Ativar o ambiente virtual
pyinstaller --onefile --clean src/main.py
'''
}
}
}
stage('Archive Executable') {
steps {
archiveArtifacts artifacts: 'dist/main', allowEmptyArchive: true
}
}
stage('Run Tests') {
steps {
script {
sh '''#!/bin/bash
. venv/bin/activate
# Wait for PostgreSQL to be ready
echo "Waiting for PostgreSQL to be ready..."
until pg_isready -h postgres -p 5432 -U test_user; do
sleep 2
done
# Create the test database
export PGPASSWORD=test_password
# Run the tests
SUPABASE_USER=test_user \
SUPABASE_PASSWORD=test_password \
SUPABASE_HOST=postgres \
SUPABASE_PORT=5432 \
SUPABASE_DATABASE=test_db \
pytest --html=report.html --self-contained-html --cov=./ --cov-report=html
'''
}
}
}
stage('Upload Test Report') {
steps {
archiveArtifacts artifacts: 'report.html', allowEmptyArchive: true
}
}
}
post {
success {
withCredentials([string(credentialsId: 'email-cred', variable: 'EMAIL')]) {
emailext subject: 'Pipeline executed successfully!',
body: 'Pipeline executed successfully. Check the logs for details.',
to: "${EMAIL}"
}
}
failure {
withCredentials([string(credentialsId: 'email-cred', variable: 'EMAIL')]) {
emailext subject: 'Failure in Pipeline Execution',
body: 'The pipeline failed. Please check the logs for details.',
to: "${EMAIL}"
}
}
}
}