修改项目构建脚本

This commit is contained in:
2026-05-10 22:23:14 +08:00
parent 3ae44d1015
commit b51bccc275
+23 -17
View File
@@ -1,34 +1,40 @@
version: 43 version: 43
jobs: jobs:
- name: 构建项目 - name: 构建项目 # 任务名称
steps: steps:
# 步骤1从代码仓库拉取代码 # ========== 步骤1:拉取代码 ==========
- type: CheckoutStep - type: CheckoutStep # 步骤类型:检出代码
name: 拉取代码 name: 拉取代码 # 步骤名称
cloneCredential: cloneCredential:
type: DefaultCredential # 使用默认凭证(当前用户权限) type: DefaultCredential # 使用默认凭证(当前用户权限)
withLfs: false # 不拉取 LFS 大文件 withLfs: false # 不拉取 Git LFS 大文件
withSubmodules: false # 不拉取子模块 withSubmodules: false # 不拉取子模块
checkoutPath: '@project_path@' # 检出到项目路径变量指定的位置 checkoutPath: '@project_path@' # 代码检出路径(OneDev 内置变量)
condition: SUCCESSFUL # 前置步骤成功时执行 condition: SUCCESSFUL # 执行条件:前置步骤成功时执行
optional: false # 此步骤不可跳过 optional: false # 不可跳过(必须执行)
# 步骤2:构建并推送 Docker 镜像 # ========== 步骤2:构建并推送 Docker 镜像 ==========
- type: BuildImageStep - type: BuildImageStep # 步骤类型:构建 Docker 镜像
name: 构建docker镜像 name: 构建docker镜像 # 步骤名称
buildPath: '@project_path@' # 构建上下文路径(项目根目录) buildPath: '@project_path@' # 构建上下文路径(项目根目录)
output: output:
type: RegistryOutput # 输出类型:推送到镜像仓库 type: RegistryOutput # 输出类型:推送到镜像仓库
tags: '@server@/recipe_tool/recipe_tool:latest' # 镜像标签格式:服务器地址/项目名/镜像名:版本 tags: '@server@/recipe_tool/recipe_tool:latest' # 镜像标签服务器地址/项目名/镜像名:版本
registryLogins: # 镜像仓库登录配置 registryLogins: # 镜像仓库登录配置
- registryUrl: https://git.hanhan.ltd # 仓库地址(带协议) - registryUrl: https://git.hanhan.ltd # 仓库地址(带协议)
userName: '@job_token@' # 用户名使用内置任务令牌 userName: '@job_token@' # 用户名使用内置任务令牌
passwordSecret: docker-push # 密码使用自定义密钥(需提前在 Job Secrets 中创建) passwordSecret: docker-push # 密码使用自定义密钥(需在 Job Secrets 中创建)
condition: SUCCESSFUL # 前置步骤成功时执行 condition: SUCCESSFUL # 执行条件:前置步骤成功时执行
optional: false # 此步骤不可跳过 optional: false # 不可跳过(必须执行)
# ========== 任务级别配置 ==========
jobExecutor: docker # 使用 Docker 执行器运行此任务 jobExecutor: docker # 使用 Docker 执行器运行此任务
triggers: # 触发器配置
- type: BranchUpdateTrigger # 触发器类型:分支更新触发
branches: main # 监听的分支(只有 main 分支更新时触发)
userMatch: anyone # 任何人提交都触发
projects: recipe_tool # 监听的项目
retryCondition: never # 失败时不自动重试 retryCondition: never # 失败时不自动重试
maxRetries: 3 # 最大重试次数(因 retryCondition: never 实际无效) maxRetries: 3 # 最大重试次数(因 retryCondition: never 实际无效)
retryDelay: 30 # 重试间隔时间(秒) retryDelay: 30 # 重试间隔时间(秒)
timeout: 14400 # 任务超时时间(4小时) timeout: 14400 # 任务超时时间(14400秒 = 4小时)