logo
0
0
WeChat Login

CNB Issue Property Updater

A CNB Issue property update plugin for CI/CD pipelines. Configured through environment variables, it uses the CNB OpenAPI to batch update custom properties of Issues.

Features

  • ✅ Support for single or batch Issue property updates
  • ✅ Easy integration into CI/CD pipelines through environment variable configuration
  • ✅ Automatic retry mechanism (1 retry for 5xx errors)
  • ✅ Structured JSON log output
  • ✅ Detailed error handling and debugging information
  • ✅ Automatic conflict resolution for properties (uses the last value for same Issue+key)
  • ✅ Idempotency support (returns success immediately for empty arrays)

CNB Pipeline Configuration

Configure in .cnb.yml:

main: push: - stages: - name: issue-property-updater image: cnbcool/issue-property-updater:latest settings: # CNB API endpoint URL, if not provided, uses the default environment variable CNB_API_ENDPOINT value cnb_api_endpoint: https://api.cnb.cool # CNB API access token, if not provided, uses the default environment variable CNB_TOKEN value token: your-api-token # Repository slug, if not provided, uses the default environment variable CNB_REPO_SLUG value repo_slug: my_slug/my-repo # Property update configuration (JSON array) properties: '[["#123","status","done"]]'

Parameter Description

Parameter NameDescriptionExample
cnb_api_endpointCNB API endpoint URL, if not provided, uses the default environment variable CNB_API_ENDPOINT valuehttps://api.cnb.cool
tokenCNB API access token, if not provided, uses the default environment variable CNB_TOKEN valueyour-api-token-here
repo_slugRepository slug, if not provided, uses the default environment variable CNB_REPO_SLUG valuemy-repo
propertiesProperty update configuration (JSON array)[["#123","status","done"]]

properties Format

Simplified Format (Recommended)

[["#123","status","done"],["repo#456","status","in_progress"]]
  • "#123" - Use default repository
  • "repo#456" - Specify repository

Full Format

[ { "repo": "my-group/my-repo", "issueNumber": 123, "key": "status", "value": "done" } ]

Local Testing

Basic Usage

# Set environment variables export PLUGIN_CNB_API_ENDPOINT="https://api.cnb.cool" export PLUGIN_CNB_TOKEN="your-api-token" export PLUGIN_REPO_SLUG="my-repo" export PLUGIN_PROPERTIES='[["#123","status","done"]]' # Run plugin bun src/cli/index.ts

Batch Update

export PLUGIN_PROPERTIES='[ ["#123","status","done"], ["#124","status","in_progress"], ["#125","priority","high"] ]' bun src/cli/index.ts

Multi-Repository Update

export PLUGIN_PROPERTIES='[ ["repo1#123","status","done"], ["repo2#456","status","in_progress"], ["my-default-repo#789","priority","high"] ]' bun src/cli/index.ts

Debug Mode

bun src/cli/index.ts --verbose --debug

Command Line Options

OptionDescription
-h, --helpDisplay help information
--versionDisplay version information
-v, --verboseEnable verbose log output
-d, --debugEnable debug mode

Output

Success Output (stdout)

{ "status": "success", "updated": 3, "failed": 0, "issues": [ { "issue": "#123", "key": "status", "success": true } ], "totalTime": 1250 }

Error Output (stderr)

{ "timestamp": "2026-01-27T10:30:00.000Z", "level": "error", "message": "API request failed", "statusCode": 404, "retryAttempted": 1, "issue": "#456", "key": "status" }

Exit Codes

Exit CodeMeaning
0Success (all properties updated successfully)
1Failure (at least one property update failed)
2Configuration error
3API error
4Network error

Error Handling

5xx Server Errors

  • Automatic retry 1 time
  • If still failing after retry, log error and continue processing next operation

4xx Client Errors

  • 401: Authentication failed, exit immediately
  • 404: Issue not found, log error and continue
  • 429: Rate limit exceeded, log warning and continue (no retry)

Property Value Validation

  • Empty key or value: log warning, continue processing
  • Value length exceeds 1000 characters: log warning, continue processing

Conflict Resolution

  • When the same Issue+key specifies multiple values, use the last value
  • Example: [["#123","status","A"],["#123","status","B"]] → final value is "B"

Local Development

# Install dependencies bun install # Run type checking bun run typecheck # Run linter bun run lint # Format code bun run format # Build project bun run build

License

MIT

About

CNB ISSUE 自定义属性 更新插件

Language
Shell60.7%
TypeScript37.1%
Dockerfile1.4%
JavaScript0.8%