-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
87 lines (85 loc) · 2.72 KB
/
Jenkinsfile
File metadata and controls
87 lines (85 loc) · 2.72 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
pipeline {
agent any
environment {
PYTHON_PATH = 'C:\\Users\\InJune\\AppData\\Local\\Programs\\Python\\Python313\\python.exe'
}
stages {
stage('Verify Python Path') {
steps {
bat """
@echo off
echo "=== 验证Python313路径及版本 ==="
${PYTHON_PATH} --version // 仅保留此关键验证(成功即证明路径正确)
echo "Python路径验证通过!"
"""
}
}
stage('Checkout') {
steps {
git url: 'https://github.com/InJunee/myflaskapp.git', branch: 'main'
}
}
stage('Fix pip') {
steps {
bat """
@echo off
echo "=== 修复Python313的pip环境 ==="
${PYTHON_PATH} -m ensurepip --upgrade
${PYTHON_PATH} -m pip --version
"""
}
}
stage('Install Dependencies') {
steps {
bat """
@echo off
${PYTHON_PATH} -m pip install --upgrade pip
${PYTHON_PATH} -m pip install -r requirements.txt
"""
}
}
stage('Lint') {
steps {
bat "${PYTHON_PATH} -m pip install flake8 && ${PYTHON_PATH} -m flake8 app.py tests/"
}
}
stage('Test') {
steps {
bat """
${PYTHON_PATH} -m pip install pytest pytest-cov
${PYTHON_PATH} -m pytest --cov=app tests/ --cov-report=html
"""
}
post {
always {
publishHTML(target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'htmlcov',
reportFiles: 'index.html',
reportName: 'Coverage Report'
])
}
}
}
stage('Build') {
steps {
bat """
${PYTHON_PATH} -m pip install pyinstaller
${PYTHON_PATH} -m PyInstaller --onefile app.py
"""
}
}
stage('Deploy') {
steps {
echo 'Deploying application...'
bat "start ${PYTHON_PATH} app.py" // 启动Flask应用(按需调整)
}
}
}
post {
success { echo 'CI/CD pipeline completed successfully!' }
failure { echo 'CI/CD pipeline failed!' }
}
}