编辑 .onedev-buildspec.yml

This commit is contained in:
2026-05-10 14:21:00 +00:00
parent 3ae44d1015
commit 8c3f2f21c3
+25 -24
View File
@@ -2,33 +2,34 @@ version: 43
jobs: jobs:
- name: 构建项目 - name: 构建项目
steps: steps:
# 步骤1:从代码仓库拉取源代码
- type: CheckoutStep - type: CheckoutStep
name: 拉取代码 name: 拉取代码
cloneCredential: cloneCredential:
type: DefaultCredential # 使用默认凭证(当前用户权限) type: DefaultCredential
withLfs: false # 不拉取 LFS 大文件 withLfs: false
withSubmodules: false # 不拉取子模块 withSubmodules: false
checkoutPath: '@project_path@' # 检出到项目路径变量指定的位置 checkoutPath: '@project_path@'
condition: SUCCESSFUL # 当前置步骤成功时执行 condition: SUCCESSFUL
optional: false # 此步骤不可跳过 optional: false
# 步骤2:构建并推送 Docker 镜像
- type: BuildImageStep - type: BuildImageStep
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
condition: SUCCESSFUL # 当前置步骤成功时执行 condition: SUCCESSFUL
optional: false # 此步骤不可跳过 optional: false
jobExecutor: docker
jobExecutor: docker # 使用 Docker 执行器运行此任务 triggers:
retryCondition: never # 失败时不自动重试 - type: BranchUpdateTrigger
maxRetries: 3 # 最大重试次数(因 retryCondition: never 实际无效) branches: main
retryDelay: 30 # 重试间隔时间(秒) userMatch: anyone
timeout: 14400 # 任务超时时间(4小时) projects: recipe_tool
retryCondition: never
maxRetries: 3
retryDelay: 30
timeout: 14400