Quick Start
About 636 wordsAbout 2 min
Cloud Native Build provides out-of-the-box CI/CD capabilities. The core concept is declarative configuration: define a series of tasks to be executed automatically when specific events occur on specific branches.
This guide covers two tasks:
- Add and run your first pipeline with NPC: skip manual config and let CodeBuddy get your first pipeline running fast
- Write a practical PR pipeline: Learn to configure a common pipeline for code quality gating
Part 1: Add Your First Pipeline with CodeBuddy
CodeBuddy is an NPC (automation agent) deeply integrated with the platform and familiar with the .cnb.yml pipeline syntax. No need to write config by hand or click through the WebIDE step by step — just tell CodeBuddy what you want in a comment and it runs your first pipeline for you.
Step 1: Prepare a Repository
If you don't have a code repository, create an empty repository under your organization first. It hosts your pipeline runs.
Step 2: Ask CodeBuddy to Add a Pipeline
Open an Issue (or a Pull Request) in the repository, enable Work Mode, then @CodeBuddy and describe what you want:
@CodeBuddy Add a pipeline to the main branch that runs when code is pushed and outputs "hello world"CodeBuddy handles the rest for you:
- Generates
.cnb.ymlat the repo root — declaring a task that runs on pushes tomainand outputshello world - Commits and pushes the config, triggering the pipeline
- Reports the execution result back in the current comment
Step 3: View the Pipeline Execution Results
Once the build starts, return to your repository homepage and open the Cloud Native Build tab to see all build records. Click the latest one (triggered by the push event) to view detailed logs and status.
Congratulations! You've completed your first CI/CD practice with CodeBuddy — no manual config needed at all.
Note
The .cnb.yml generated above is equivalent to what you would write by hand; its full syntax is explained in Part 2.
Part 2: Write a Practical PR Validation Pipeline
Now let's implement a more practical scenario: Configure a Pull Request pipeline for the main branch to automatically perform code checks (lint) and tests (test), and notify the team upon failure.
1. Define the Branch, Event and Tasks
First, specify the target branch (main) and the event (pull_request), then define a pipeline named pr-check with two sequentially executed tasks.
main:
pull_request:
- name: pr-check
stages:
- name: lint
script: echo "Running linting tools..."
- name: test
script: echo "Running test suites..."2. Define Failure Handling
If any task in the main sequence fails, use failStages to automatically execute alert tasks.
main:
pull_request:
- name: pr-check
stages:
- name: lint
script: echo "Running linting tools..."
- name: test
script: echo "Running test suites..."
failStages:
- name: notify-team
script: echo "Notifying the chat group that the PR check failed!"Pipeline Execution Logic:
- Listen for
pull_requestevents on themainbranch. - Start the
pr-checkpipeline. - Execute the tasks in
stagesin order (lint → test). - If all tasks succeed, the pipeline status is marked as passed.
- If any task fails, abort immediately and execute the tasks in
failStagesinstead.
Next Steps
- 🔧 Dive Deeper into Configuration: Check out the Configuration Details to explore more advanced features.
- 📖 Master the Full Syntax: Go to the Syntax Guide to learn about all configuration items.
- 🚀 Reference Real-World Examples: Need more inspiration? Visit Best Practices(Open in new window) to fork sample repositories or reuse their configurations to quickly customize your pipeline.