主要更新: - 使用SSH私钥认证替代用户名密码认证 - 配置deploy-server-ssh-key凭据ID - 修复Jenkinsfile格式和缩进问题 - 添加SSH配置指南和企业级部署文档 技术改进: - 使用sshagent进行安全的SSH连接 - 移除sshpass依赖,提升安全性 - 统一使用root@116.62.163.84进行部署 - 优化Docker镜像传输和部署流程 新增文档: - SSH_CONFIG_GUIDE.md - SSH私钥配置指南 - ENTERPRISE_JENKINS_GUIDE.md - 企业级Jenkins部署 - jenkins-docker/ - Jenkins Docker化部署方案
145 lines
2.8 KiB
YAML
145 lines
2.8 KiB
YAML
# CI/CD项目配置文件
|
||
# 文件名: .ci-config.yml
|
||
# 放置在项目根目录
|
||
|
||
# 项目基本信息
|
||
project:
|
||
name: "jenkins-demo"
|
||
type: "java-maven" # 支持: java-maven, java-gradle, nodejs, python, dotnet
|
||
version: "1.0.0"
|
||
description: "Spring Boot演示项目"
|
||
|
||
# 构建配置
|
||
build:
|
||
# JDK版本(java项目专用)
|
||
jdk: "17"
|
||
|
||
# Maven配置(java-maven项目专用)
|
||
maven:
|
||
goals: ["clean", "compile", "test", "package"]
|
||
profiles: ["default"]
|
||
skip_tests: false
|
||
|
||
# Node.js配置(nodejs项目专用)
|
||
nodejs:
|
||
version: "18"
|
||
package_manager: "npm" # npm, yarn, pnpm
|
||
build_command: "npm run build"
|
||
test_command: "npm test"
|
||
|
||
# Python配置(python项目专用)
|
||
python:
|
||
version: "3.9"
|
||
requirements_file: "requirements.txt"
|
||
test_command: "pytest"
|
||
|
||
# 自定义构建命令
|
||
custom_commands:
|
||
pre_build: []
|
||
post_build: []
|
||
|
||
# 测试配置
|
||
test:
|
||
unit_tests:
|
||
enabled: true
|
||
command: "mvn test"
|
||
reports: "target/surefire-reports/*.xml"
|
||
|
||
integration_tests:
|
||
enabled: true
|
||
command: "mvn verify -Pintegration-test"
|
||
reports: "target/failsafe-reports/*.xml"
|
||
|
||
coverage:
|
||
enabled: true
|
||
tool: "jacoco" # jacoco, cobertura
|
||
threshold: 80
|
||
reports: "target/site/jacoco/jacoco.xml"
|
||
|
||
# 代码质量
|
||
quality:
|
||
sonarqube:
|
||
enabled: true
|
||
project_key: "jenkins-demo"
|
||
host_url: "http://116.62.163.84:15010"
|
||
quality_gate: true
|
||
|
||
checkstyle:
|
||
enabled: false
|
||
config_file: "checkstyle.xml"
|
||
|
||
spotbugs:
|
||
enabled: false
|
||
|
||
# Docker配置
|
||
docker:
|
||
enabled: true
|
||
dockerfile: "Dockerfile"
|
||
image_name: "jenkins-demo"
|
||
registry: "" # 私有镜像仓库地址,空表示本地
|
||
build_args: {}
|
||
|
||
# 部署配置
|
||
deploy:
|
||
target: "test" # test, staging, production
|
||
|
||
# 测试环境
|
||
test:
|
||
server: "116.62.163.84"
|
||
port: 8080
|
||
health_check: "/api/health"
|
||
container_name: "jenkins-demo-test"
|
||
|
||
# 预发布环境
|
||
staging:
|
||
server: "116.62.163.84"
|
||
port: 8090
|
||
health_check: "/api/health"
|
||
container_name: "jenkins-demo-staging"
|
||
|
||
# 生产环境
|
||
production:
|
||
server: "116.62.163.84"
|
||
port: 80
|
||
health_check: "/api/health"
|
||
container_name: "jenkins-demo-prod"
|
||
manual_approval: true
|
||
|
||
# 通知配置
|
||
notifications:
|
||
email:
|
||
enabled: false
|
||
recipients: ["dev-team@company.com"]
|
||
|
||
slack:
|
||
enabled: false
|
||
channel: "#ci-cd"
|
||
webhook_url: ""
|
||
|
||
dingtalk:
|
||
enabled: false
|
||
webhook_url: ""
|
||
secret: ""
|
||
|
||
# 高级配置
|
||
advanced:
|
||
# 并行构建
|
||
parallel_builds: true
|
||
|
||
# 缓存配置
|
||
cache:
|
||
maven_repository: true
|
||
node_modules: true
|
||
pip_cache: true
|
||
|
||
# 安全扫描
|
||
security:
|
||
dependency_check: true
|
||
image_scan: true
|
||
|
||
# 构建超时(分钟)
|
||
timeout: 30
|
||
|
||
# 保留构建数量
|
||
build_retention: 10
|