-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
65 lines (59 loc) · 2.2 KB
/
Copy pathJenkinsfile
File metadata and controls
65 lines (59 loc) · 2.2 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
// =============================================================
// Jenkinsfile(备查——CI/CD 示意流水线)
//
// 阶段:
// 1. 单元测试(全 mock,不依赖外部服务,快)
// 2. 构建镜像
// 3. (可选)评估:起服务 → 跑 evaluate.py → 留存报告
//
// 【设计点:为什么评估不放进每次 CI(面试点)】
// 评估跑 15 条用例 = 15 次 Agent 请求 × 8~12 次 LLM 调用,
// 每次 CI 都跑成本高(token 费用)且耗时长。
// 合理策略:单元测试每次 PR 必跑(秒级),完整评估
// 在版本发布 / 模型切换 / prompt 大改时手动触发或定时跑——
// 模型行为没变时,重跑评估没有信息增量。
// =============================================================
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Unit Tests') {
steps {
sh 'pip install -r requirements.txt'
sh 'cd backend && python -m pytest tests/ -v'
}
}
stage('Build Image') {
steps {
sh 'docker build -f docker/Dockerfile -t enterprise-agent:latest .'
}
}
stage('Evaluation (manual)') {
when {
// 评估耗 token,仅在手动触发时执行(见文件头注释)
expression { params.RUN_EVALUATION == true }
}
steps {
sh '''
docker compose -f docker/docker-compose.yml up -d --build
sleep 30
docker compose -f docker/docker-compose.yml exec app python -m app.database.seed
python evaluation/evaluate.py --api-url http://localhost:8000
'''
}
post {
always {
archiveArtifacts artifacts: 'evaluation/evaluation_report.json', allowEmptyArchive: true
}
}
}
}
parameters {
booleanParam(name: 'RUN_EVALUATION', defaultValue: false,
description: '是否运行完整 Agent 评估(消耗 LLM token)')
}
}