KFParser CLI Integration Guide for CI/CD Pipelines

📋 Overview

The KFParser CLI provides a cross-platform solution for parsing and visualizing project architectures across continuous integration environments.

🛠 Prerequisites

  • Supported CI/CD Platforms

    • GitHub Actions
    • Jenkins
    • Buildkite
    • AWS CodePipeline
  • Operating System Compatibility

    • Linux
    • Windows
    • macOS

🔐 Credential Management

  1. Use CI/CD platform secret management
  2. Create environment variables:
    • KLOUDFARM_EMAIL
    • KLOUDFARM_PASSWORD
    • KLOUDFARM_PROJECT_ID

🚀 Universal Preparation Steps

Linux/macOS Environments

# Download appropriate executable
wget https://downloads.kloudfarm.io/prod/latest/kfclient-linux-cli -O kfparser

# Set executable permissions
chmod +x kfparser

# Optional: Move to system path
sudo mv kfparser /usr/local/bin/

Windows Environments

# Download executable
Invoke-WebRequest -Uri "https://downloads.kloudfarm.io/prod/latest/kfclient-windows-cli.exe" -OutFile kfparser.exe

🔧 Platform-Specific Configurations

Buildkite Pipeline

steps:
  - label: "KFParser Architecture Analysis"
    plugins:
      - docker#v5.3.0:
          image: "ubuntu:latest"
    env:
      KLOUDFARM_EMAIL: "${KLOUDFARM_EMAIL}"
      KLOUDFARM_PASSWORD: "${KLOUDFARM_PASSWORD}"
      KLOUDFARM_PROJECT_ID: "${KLOUDFARM_PROJECT_ID}"
    commands:
      - |
        # Download KFParser CLI
        wget https://downloads.kloudfarm.io/prod/latest/kfclient-linux-cli -O kfparser
        chmod +x kfparser

        # Run Architecture Analysis
        ./kfparser analyze $BUILDKITE_BUILD_CHECKOUT_PATH \
          --email $KLOUDFARM_EMAIL \
          --password $KLOUDFARM_PASSWORD \
          --project-id $KLOUDFARM_PROJECT_ID \
          --parser all \
          --auto-upload

  # Optional: Add a conditional step for specific branches
  - label: "Selective Parser Execution"
    if: build.branch == "main"
    plugins:
      - docker#v5.3.0:
          image: "ubuntu:latest"
    commands:
      - |
        wget https://downloads.kloudfarm.io/prod/latest/kfclient-linux-cli -O kfparser
        chmod +x kfparser
        ./kfparser analyze $BUILDKITE_BUILD_CHECKOUT_PATH \
          --email $KLOUDFARM_EMAIL \
          --password $KLOUDFARM_PASSWORD \
          --project-id $KLOUDFARM_PROJECT_ID \
          --parser application \
          --view

Buildkite-Specific Considerations

Environment Setup

  • Use Buildkite's secret management for credentials
  • Configure organization-level or pipeline-level environment variables

Advanced Configuration

steps:
  - label: "Comprehensive KFParser Analysis"
    env:
      PARSER_TYPE: "all"
      AUTO_UPLOAD: "true"
    commands:
      - |
        ./kfparser analyze $BUILDKITE_BUILD_CHECKOUT_PATH \
          --email $KLOUDFARM_EMAIL \
          --password $KLOUDFARM_PASSWORD \
          --project-id $KLOUDFARM_PROJECT_ID \
          --parser $PARSER_TYPE \
          ${AUTO_UPLOAD:+--auto-upload} \
          ${AUTO_UPLOAD:+--no-upload}

Buildkite-Specific Best Practices

  1. Utilize conditional step execution
  2. Leverage environment variables
  3. Implement flexible parsing strategies
  4. Use Docker plugins for consistent environments

GitHub Actions Workflow

name: KFParser Architecture Analysis

on: [push]

jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Download KFParser
      run: |
        wget https://downloads.kloudfarm.io/prod/latest/kfclient-linux-cli -O kfparser
        chmod +x kfparser
    - name: Run KFParser Analysis
      env:
        KLOUDFARM_EMAIL: ${{ secrets.KLOUDFARM_EMAIL }}
        KLOUDFARM_PASSWORD: ${{ secrets.KLOUDFARM_PASSWORD }}
        KLOUDFARM_PROJECT_ID: ${{ secrets.KLOUDFARM_PROJECT_ID }}
      run: |
        ./kfparser analyze ${{ github.workspace }} \
          --email $KLOUDFARM_EMAIL \
          --password $KLOUDFARM_PASSWORD \
          --project-id $KLOUDFARM_PROJECT_ID \
          --parser all

Jenkins Pipeline

pipeline {
    agent any
    environment {
        KLOUDFARM_CREDENTIALS = credentials('kloudfarm-credentials')
    }
    stages {
        stage('Download KFParser') {
            steps {
                sh '''
                    wget https://downloads.kloudfarm.io/prod/latest/kfclient-linux-cli -O kfparser
                    chmod +x kfparser
                '''
            }
        }
        stage('Architecture Analysis') {
            steps {
                sh '''
                    ./kfparser analyze $WORKSPACE \
                    --email $KLOUDFARM_CREDENTIALS_USR \
                    --password $KLOUDFARM_CREDENTIALS_PSW \
                    --project-id $KLOUDFARM_PROJECT_ID \
                    --parser all
                '''
            }
        }
    }
}

AWS CodePipeline (buildspec.yml)

version: 0.2

phases:
  install:
    commands:
      - wget https://downloads.kloudfarm.io/prod/latest/kfclient-linux-cli -O kfparser
      - chmod +x kfparser
  build:
    commands:
      - ./kfparser analyze . 
          --email $KLOUDFARM_EMAIL 
          --password $KLOUDFARM_PASSWORD 
          --project-id $KLOUDFARM_PROJECT_ID 
          --parser all

🔍 Parsing Strategy Options

# All parsers (default)
./kfparser analyze . --parser all

# Application parser only
./kfparser analyze . --parser application

# Kubernetes parser only
./kfparser analyze . --parser kubernetes

🛡️ Security Considerations

  1. Use ephemeral credentials
  2. Implement credential rotation
  3. Limit parser scope
  4. Monitor and log analysis activities

🐛 Troubleshooting Strategies

Common Challenges

  • Network connectivity issues
  • Credential verification
  • Parser compatibility
  • Execution permissions

Debugging Approaches

  • Use --view flag for detailed output
  • Check CI/CD platform logs
  • Validate credentials separately
stages:
  - prepare_environment
  - download_kfparser
  - run_architecture_analysis
  - build
  - deploy

🚀 Best Practices

  • Integrate early in CI/CD pipeline
  • Configure result notifications
  • Implement periodic full scans
  • Maintain consistent executable versions

⚠️ Version Management

  • Pin to specific CLI version
  • Regularly update executable
  • Check compatibility before upgrades

💡 Advanced Configuration

Selective Deployment

  • Conditionally run parser based on branch
  • Set up parser-specific workflows
  • Implement granular access controls

🔗 Additional Resources