Pipeline automation - Automate agent deployments in CI/CD workflows
Infrastructure as Code - Version control your AI agent configurations
Multi-environment management - Deploy agents to different environments
Key CI/CD Features
Non-Interactive Mode
Kubiya CLI provides a CI mode for automation pipelines where user prompts are not possible:
# Sync a specific source in CI mode (no prompts)
kubiya source sync SOURCE_ID --mode ci
# Sync all sources in CI mode
kubiya source sync --all --mode ci
Machine-Readable Output
Get structured output formats for easy parsing in CI scripts:
# JSON output for parsing in scripts
kubiya source list --output json
kubiya teammate list --output json
API Key Configuration
Configure authentication securely in CI environments:
# Set API key from CI secret/environment variable
kubiya config set api-key "$KUBIYA_API_KEY"
CI/CD Platform Integration Examples
GitHub Actions Integration
# .github/workflows/kubiya-sync.yml
name: Sync Kubiya Sources
on:
push:
branches: [ main ]
paths:
- 'kubiya-sources/**'
jobs:
sync-kubiya-sources:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Kubiya CLI
run: curl -fsSL https://cli.kubiya.ai/install | sh
- name: Configure Kubiya
run: kubiya config set api-key ${{ secrets.KUBIYA_API_KEY }}
- name: Sync Sources
run: |
# List current sources
kubiya source list --output json > sources_before.json
# Sync all sources in CI mode
kubiya source sync --all --mode ci
# Verify sources after sync
kubiya source list --output json > sources_after.json
pipeline {
agent any
stages {
stage('Install Kubiya CLI') {
steps {
sh 'curl -fsSL https://cli.kubiya.ai/install | sh'
sh 'kubiya config set api-key ${KUBIYA_API_KEY}'
}
}
stage('Sync Sources') {
steps {
sh 'kubiya source sync --all --mode ci'
}
}
stage('Deploy AI Tools') {
steps {
sh 'kubiya tool execute deploy-tools --args \'{"environment":"production"}\''
}
}
}
}
Common CI/CD Use Cases
1. Automated Source Management
Implementation Example
#!/bin/bash
# CI script for managing Kubiya sources
# Setup
curl -fsSL https://cli.kubiya.ai/install | sh
kubiya config set api-key "$KUBIYA_API_KEY"
# Check if source exists
SOURCE_NAME="deployment-tools"
SOURCE_EXISTS=$(kubiya source list --output json | jq -r --arg name "$SOURCE_NAME" '.[] | select(.name==$name) | .id')
if [ -z "$SOURCE_EXISTS" ]; then
# Create new source if it doesn't exist
echo "Creating new source: $SOURCE_NAME"
kubiya source add --name "$SOURCE_NAME" \
--url "https://github.com/organization/deployment-tools" \
--branch main
else
# Sync existing source
echo "Syncing existing source: $SOURCE_NAME (ID: $SOURCE_EXISTS)"
kubiya source sync "$SOURCE_EXISTS" --mode ci
fi
# Verify tools are available after sync
echo "Available tools:"
kubiya tool list --output json | jq -r '.[].name'
2. Multi-Environment Deployment
Create scripts for managing different environments:
#!/bin/bash
# deploy-to-env.sh
# Usage: ./deploy-to-env.sh [staging|production]
ENV=$1
if [ -z "$ENV" ]; then
echo "Error: Environment not specified"
echo "Usage: ./deploy-to-env.sh [staging|production]"
exit 1
fi
# Set environment-specific variables
case "$ENV" in
staging)
API_KEY=$KUBIYA_STAGING_API_KEY
RUNNER="staging-runner"
;;
production)
API_KEY=$KUBIYA_PRODUCTION_API_KEY
RUNNER="production-runner"
;;
*)
echo "Error: Unknown environment '$ENV'"
echo "Supported environments: staging, production"
exit 1
;;
esac
# Configure CLI for environment
kubiya config set api-key "$API_KEY"
# Sync sources for environment
kubiya source sync --all --mode ci
# Deploy with environment-specific parameters
kubiya tool execute deploy-app --args "{\"environment\":\"$ENV\",\"runner\":\"$RUNNER\"}"
echo "Deployment to $ENV complete"
3. GitOps Workflow
Implement GitOps for Kubiya resources:
#!/bin/bash
# GitOps sync script for Kubiya resources
# Create directories for Kubiya configurations
mkdir -p .kubiya/{sources,teammates,webhooks}
# Export current configurations as code
kubiya source list --output json > .kubiya/sources/current.json
kubiya teammate list --output json > .kubiya/teammates/current.json
kubiya webhook list --output json > .kubiya/webhooks/current.json
# Commit to version control
git add .kubiya
git commit -m "Update Kubiya resource configurations"
git push
# In CI pipeline, apply configurations:
# kubiya source sync --all --mode ci
Common Commands for CI/CD Integration
Source Management
# List sources in JSON format for CI processing
kubiya source list --output json
# Add a new source programmatically
kubiya source add --name "ci-tools" \
--url "https://github.com/org/ci-tools" \
--branch main
# Sync a specific source in CI mode
kubiya source sync SOURCE_ID --mode ci
# Sync all sources in CI mode
kubiya source sync --all --mode ci
Tool Execution
# Execute a tool with JSON arguments
kubiya tool execute deploy-app --args '{"environment":"production","version":"1.2.3"}'
# List available tools in JSON format
kubiya tool list --output json
# Search for specific tools
kubiya tool search "deploy" --output json
Webhook Management
# Create a webhook programmatically
kubiya webhook create --name "ci-webhook" \
--source "github" \
--method "HTTP"
# Get webhook URL for repository configuration
WEBHOOK_URL=$(kubiya webhook describe WEBHOOK_ID --format url)
Store API Keys Securely: Always use CI/CD platform's secret management for API keys
Use Non-Interactive Mode: Always use --mode ci for source syncing in pipelines
Output JSON for Parsing: Use --output json for programmatic processing
Handle Errors Properly: Implement proper error handling in CI scripts
Version Control Configurations: Keep Kubiya resource definitions in version control
Implement Idempotency: Make scripts safe to run multiple times
Maintain Environment Separation: Use separate API keys and configurations for each environment
Conclusion
Integrating Kubiya CLI into CI/CD pipelines enables automation of AI agent management, ensuring that your AI capabilities are developed, tested, and deployed with the same rigor as your application code. By following the examples and best practices in this guide, you can build robust CI/CD pipelines that seamlessly incorporate AI agent management into your DevOps workflows.