Building automated promotion pipelines from Dev to Staging to Production using CLI export bundles and test automation.
Manually re-creating tools and agents across Dev, Staging, and Production tenants is slow and error-prone. In this lab, we build a production-grade CI/CD pipeline using the Orchestrate CLI to export self-contained bundles, unpack dependencies, validate schemas, and promote across environments.
cicd_promoter.py)#!/usr/bin/env python3
import subprocess
import os
import sys
def run_cmd(cmd):
print(f"👉 Executing: {cmd}")
res = subprocess.run(cmd, shell=True, capture_output=True, text=True)
if res.returncode != 0:
print(f"❌ Error: {res.stderr}")
sys.exit(res.returncode)
return res.stdout
def export_and_promote(agent_name, target_env="staging"):
bundle_path = f"/tmp/{agent_name}_bundle.zip"
print(f"📦 Step 1: Exporting {agent_name} from Dev...")
run_cmd(f"orchestrate agents export -n {agent_name} -k native -o {bundle_path}")
print(f"🔄 Step 2: Activating target environment '{target_env}'...")
run_cmd(f"orchestrate env activate {target_env}")
print(f"📥 Step 3: Unpacking and importing bundle to {target_env}...")
run_cmd(f"orchestrate agents import -f {bundle_path}")
print(f"✅ Promotion of '{agent_name}' to '{target_env}' COMPLETE!")
if __name__ == "__main__":
export_and_promote("hello_world_greeter", target_env="staging")
requirements.txt)ibm-watsonx-orchestrate>=2.9.0
agent.yaml)# Sample export manifest
spec_version: v1
kind: native
name: hello_world_greeter
title: "Hello World Greeter (v2.1.0)"
model: ibm/granite-3-8b-instruct
tools:
- greet_user
python3 cicd_promoter.py
👉 Executing: orchestrate agents export -n hello_world_greeter -k native -o /tmp/hello_world_greeter_bundle.zip
👉 Executing: orchestrate env activate staging
👉 Executing: orchestrate agents import -f /tmp/hello_world_greeter_bundle.zip
✅ Promotion of 'hello_world_greeter' to 'staging' COMPLETE!
Export bundles intentionally exclude raw API keys and connection passwords. Use environment-specific `.env` or KeyProtect vaults in staging/prod.
Always update the agent's title or version tag in YAML before committing to git.