SuperAPI AI Directory

bk-cli-job

Deployment & operations

View repository

Updated 10-16 09:55

About this skill

bk-cli job — Job Platform Capability Usage Instructions

Used to call BlueKing Job Platform (BK-JOB) API system subcommands via bk-cli job .

CRITICAL — Before starting, you MUST first use the Read tool to read ../bk-cli-shared/SKILL.md. The shared skill handles authentication, context, tenant, stage, dry-run, verbose, header/body, and general request rules; this skill only supplements job the command's own semantics and input conventions.

Current Coverage

This skill currently covers these commonly used commands:

  • get_job_instance_status
  • get_job_instance_ip_log
  • fast_transfer_file
  • push_config_file
  • fast_execute_script

Commands

Query Type

get_job_instance_status

bk-cli job get_job_instance_status --bk_biz_id 2 --job_instance_id 100
bk-cli job get_job_instance_status --bk_biz_id 2 --job_instance_id 100 --return_ip_result
  • Query job instance execution status
  • Call path:GET /api/v3/get_job_instance_status

get_job_instance_ip_log

bk-cli job get_job_instance_ip_log --bk_biz_id 2 --job_instance_id 100 --step_instance_id 200 --bk_cloud_id 0 --ip 10.0.0.1
  • Query the job execution log of a certain host
  • Call path:GET /api/v3/get_job_instance_ip_log

Execution Type

fast_execute_script

bk-cli job fast_execute_script --bk_biz_id 2 --script_content "echo hello" --script_language shell --account_alias root --target_server '{"host_id_list":[1]}'
bk-cli job fast_execute_script --bk_biz_id 2 --script_file ./script.sh --script_language shell --account_alias root --target_server '{"host_id_list":[1]}'
bk-cli job fast_execute_script --body '{"bk_biz_id":2,"target_server":{"host_id_list":[1]},"script_language":1,"script_content":"ZWNobyBoZWxsbw=="}'
  • Quickly execute a script,script_content / script_file must choose one of the two; if not explicitly provided --body at least one of them must be provided
  • From --script_file the script content read will also, like script_param , be Base64-encoded before sending
  • script_language supports: shell, bat, perl, python, powershell
  • If not explicitly provided --body ,target_server must be passed via --target_server as a JSON object
  • If explicitly provided --body , the complete request body must be passed; no partial merging with other flags will be performed
  • Call path:POST /api/v3/fast_execute_script

fast_transfer_file

bk-cli job fast_transfer_file --body '{"bk_scope_type":"biz","bk_scope_id":"2","bk_biz_id":2,...}'
  • Quickly distribute files; the payload is relatively complex and must be provided via --body as complete JSON
  • Call path:POST /api/v3/fast_transfer_file

push_config_file

bk-cli job push_config_file --body '{"bk_scope_type":"biz","bk_scope_id":"2","bk_biz_id":2,"file_list":[...],...}'
  • Distribute a local configuration file,file_list in content the field must be Base64-encoded
  • Call path:POST /api/v3/push_config_file

When to fall back to bk-cli api

  • The Job API to be called is not in the above list
  • Need to fully customize body/header