bk-job

Operate BlueKing Job platform APIs to run scripts, transfer files, and manage cron tasks.

866|216|Updated Jun 17, 2021
One-click install
npx skills add https://github.com/TencentBlueKing/bk-job --skill bk-job
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bk-job
Source: https://github.com/TencentBlueKing/bk-job/tree/main/ai_agent/user/skills/bk-job
Command: npx skills add https://github.com/TencentBlueKing/bk-job --skill bk-job

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

It lets an AI agent perform BlueKing Job (bk-job) operations through the API gateway without manual console work: searching cron tasks, job templates, execution plans and instance logs, creating plans and cron tasks, executing scripts on target hosts, and distributing files, all with strict confirmation gates for write operations.

Core Features & Use Cases

  • Script execution and file distribution: Run fast_execute_script on selected hosts and distribute server or local files to target machines via fast_transfer_file, with dry-run previews and mandatory user confirmation before any write.
  • Job orchestration management: Search templates, create execution plans, launch plans, create and enable cron tasks, and query execution history, instance status, and step logs.
  • Scoped, tenant-aware operations: Select biz or biz_set scopes, query host topology and execution accounts before filling parameters, and switch tenants per request via --bk-tenant-id.
  • Use Case: Ask the agent to restart a service on specific servers; it locates the hosts and account, shows a full confirmation summary including default parameters, waits for your explicit confirmation, executes the script, and returns a clickable job instance link.

Quick Start

Ask the agent to list authorized business scopes, then request something like "run this shell script on hosts 10.0.0.1 and 10.0.0.2 with the root account" and confirm the summary it presents.

Frequently Asked Questions about bk-job

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I execute a script on remote servers with BlueKing Job API?

Use the fast-execute-script subcommand with the target hosts (--host-id-list or --ip-list as bk_cloud_id:ip), an execution account, and the script content or script ID. Run with --dry-run first to preview the request, then confirm the summary before real execution.

How to distribute files to target machines via bk-job?

Use fast-transfer-file with either server files (file_type=1, requiring source host and account) or local files (file_type=2, uploaded first via gen-local-upload-url and upload-local-file). Third-party file sources like COS are not supported by this skill.

What permissions and credentials does the bk-job API client need?

It needs a user access token obtained from the ai-hub command or the BK_JOB_ACCESS_TOKEN environment variable, plus gateway URLs configured in config.yaml. The token is sent in the X-Bkapi-Authorization header, and a tenant ID is resolved from CLI, config, or default.

Why does the agent ask for confirmation before running a job?

All write operations (plan-execute, fast-execute-script, fast-transfer-file, plan-create, cron-save, cron-update-status) require a confirmation summary followed by a separate user reply. This gate cannot be skipped, even for repeated executions with identical parameters.

How far back can I query job execution history?

Execution history queries via cron-last-run and instance-list are limited to a maximum lookback of 31 days. Requests beyond that are truncated to 31 days with a notice in the output.

Can I operate resources in a different tenant with bk-job?

Yes, pass --bk-tenant-id before the subcommand to override the tenant for that call. Priority is CLI argument over config.yaml's bk_tenant_id over the default value, and the agent should confirm the tenant with you rather than guess.