name: edit-build-spec
description: Author or update .onedev-buildspec.yml for OneDev CI/CD. Use when the user asks to create, configure, or modify a OneDev build spec.
Edit OneDev CI/CD spec
Author or update .onedev-buildspec.yml for the current OneDev project.
Prerequisites
todis installed and configured.- The current directory is the project root where
.onedev-buildspec.ymlbelongs.
Workflow
- Fetch the spec schema first. Before editing anything, get the authoritative
spec schema so the generated YAML matches the server's expectations:
tod build get-spec-schema - If a CI/CD spec already exists, validate and upgrade it first:
This both validates and upgrades the file to the latest version when needed.tod build check-spec - Inspect the project. Read the files you need (package manifests, language version files, Dockerfiles, etc.) to understand what image and commands the job should use.
- Edit
.onedev-buildspec.ymlapplying the user's instruction and the rules below. - Validate again after editing:
Keep iterating untiltod build check-spectod build check-specsucceeds.
Authoring rules
When writing or modifying .onedev-buildspec.yml:
- A checkout step is generally needed to clone repository into job working directory
- Always call
tod build get-spec-schemafirst so the YAML you produce matches the spec schema. - If a
commandstep is used, enable "run in container" unless the user explicitly asks otherwise. - Different steps run in isolated environments and only share the job working directory. Installing dependencies in one step and running commands that rely on them in another will not work. Keep them in a single step unless the user explicitly wants them separated.
- If a
cachestep is used:- Place it before the step that builds or tests the project.
- If the project has lock files (
package.json,pom.xml, etc.):- Configure checksum files using these lock files.
- Configure the upload strategy as
UPLOAD_IF_NOT_HIT.
- To pass files between jobs, have the producing job publish them with the publish-artifact step, and let consuming jobs pull them in via a job dependency.
- Call
tod build check-specbefore editing an existing CI/CD spec to make sure it is valid and up to date. - Inspect the relevant project files to decide which docker image and commands to use when the user asks you to set up build or test steps.
- Call
tod build check-specagain after editing so the final spec is confirmed valid.