Automating Agent CI/CD Lifecycle: Exporting, Versioning, and Promoting watsonx Orchestrate Agents

WXO Labs Series Icon 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

Automating Agent CI/CD Lifecycle: Exporting, Versioning, and Promoting watsonx Orchestrate Agents

Why This Pattern Matters

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.


πŸ“‹ Prerequisites & Setup

Ensure your environment has the required dependencies:

pip install ibm-watsonx-orchestrate

Verify active environment:

orchestrate env list

πŸ› οΈ Step 1: Implement the Logic (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")

πŸ“¦ Step 2: Declare Dependencies (requirements.txt)

ibm-watsonx-orchestrate>=2.9.0

πŸ€– Step 3: Configure the AI Agent (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

πŸš€ Step 4: Import & Test Live in Terminal

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!

πŸ’‘ Pro Tips & Gotchas


🏷️ Recommended Community Tags

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


πŸ—ΊοΈ Series Roadmap (15 Hands-On Labs)

This tutorial is Part 11 of 15 in the complete enterprise hands-on series:

Explore the interactive curriculum and code repository: