By Markus van Kempen |
Series: WXO Labs & Tutorial Guide (Part 11 of 15)
Interactive Lab Portal: https://markusvankempen.github.io/wxo-labs/
GitHub Repository: https://github.com/markusvankempen/wxo-labs
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.
Ensure your environment has the required dependencies:
pip install ibm-watsonx-orchestrate
Verify active environment:
orchestrate env list
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
Import tool and test conversationally:
python3 cicd_promoter.py
Live Response:
π 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!
When publishing this blog post, select or enter the following tags in the community editor:
watsonx Orchestrate, CI/CD, DevOps, Agent Lifecycle, CLI Automation, GitOps, Deployment Pipeline
This tutorial is Part 11 of 15 in the complete enterprise hands-on series:
Explore the interactive curriculum and code repository: