Git File Browser

User: usernamegoeshere | Repo: platformhubrepo
← Back
self-support.ocl
name = "Self Support"
description = "Adds a self support step that queries GitHub issues to diagnose a failed deployment"

parameter "SelfSupport.WorkerPool" {
    display_settings = {
        Octopus.ControlType = "WorkerPool"
    }
    help_text = ""
    label = ""
}

parameter "SelfSupport.Claude.ApiKey" {
    display_settings = {
        Octopus.ControlType = "Sensitive"
    }
    help_text = ""
    label = ""
}

parameter "SelfSupport.Octopus.ApiKey" {
    display_settings = {
        Octopus.ControlType = "Sensitive"
    }
    help_text = ""
    label = ""
}

parameter "SelfSupport.GitHub.PAT" {
    display_settings = {
        Octopus.ControlType = "Sensitive"
    }
    help_text = ""
    label = ""
}

parameter "SelfSupport.RunCondition" {
    display_settings = {
        Octopus.ControlType = "SingleLineText"
    }
    help_text = "Set to `#{if Octopus.Deployment.Error}True#{/if}` to run on any failed deployment."
    label = ""
}

step "run-claude-agent" {
    condition = "Variable"
    name = "Run Claude Agent"
    properties = {
        Octopus.Step.ConditionVariableExpression = "#{SelfSupport.RunCondition}"
    }

    action {
        action_type = "Octopus.Claude"
        properties = {
            Octopus.Action.Claude.ApiKey = "#{SelfSupport.Claude.ApiKey}"
            Octopus.Action.Claude.Effort = "high"
            Octopus.Action.Claude.InjectionCheckEnabled = "False"
            Octopus.Action.Claude.MaxTurns = "100"
            Octopus.Action.Claude.McpServers = "[{\"type\":\"http\",\"name\":\"GitHub\",\"url\":\"https://api.githubcopilot.com/mcp/\",\"headers\":{\"Authorization\":\"#{SelfSupport.GitHub.PAT}\"},\"env\":{},\"allowedTools\":[\"*\"]}]"
            Octopus.Action.Claude.Model = "claude-haiku-4-5"
            Octopus.Action.Claude.OctopusMcpApiKey = "#{SelfSupport.Octopus.ApiKey}"
            Octopus.Action.Claude.OctopusMcpTools = "[\"*\"]"
            Octopus.Action.Claude.Permissions = "{\"deny\":[\"Read\", \"Write\", \"Bash\", \"WebFetch\", \"WebSearch\", \"Grep\", \"Glob\"]}"
            Octopus.Action.Claude.Prompt = <<-EOT
                The deployment #{Octopus.Deployment.Id} in space #{Octopus.Space.Name} for project #{Octopus.Project.Name} has failed.

                Your task is to provide guidance on how to troubleshoot and resolve the issue.

                Provide a solution to the failure by:

                * Getting the Octopus deployment logs and determining which step failed
                * Getting the configuration of the deployment steps
                * Getting any git diffs from the commits noted in the build information
                * If the project is configured with config-as-code, checking the git repo hosting the project configuration for any recent changes
                * Checking the GitHub issues at https://github.com/OctopusSolutionsEngineering/SelfSupportDemo for any relevant issues or known bugs that match the failed step

                # Notes

                * You must only use the MCP servers to gather information.
                * You must not run any scripts, execute curl, or run any other CLI tools to gather information.
                * You must not list every issue you find in GitHub.
                * You must only reference an issue if it is directly related to the current deployment failure.

                # Output

                The output must be plain text. Do not use markdown formatting.

                Use dashes to indicate headings, for example:

                ```
                ---------
                Heading 1
                ---------
                ```

                Use asterisks to indicate bullet points, for example:

                ```
                * Bullet point 1
                * Bullet point 2
                ```
                EOT
            Octopus.Action.Claude.SandboxMode = "None"
            Octopus.Action.ExecutionTimeout.Minutes = "10"
            Octopus.Action.RunOnServer = "true"
        }
        worker_pool_variable = "#{SelfSupport.WorkerPool}"

        container {
            dockerfile = <<-EOT
                    FROM python:3.11-slim

                    # 1. Install prerequisites (including libicu for .NET Calamari compatibility)
                    RUN apt-get update && apt-get install -y --no-install-recommends \
                        curl \
                        git \
                        libicu-dev \
                        ca-certificates \
                        npm \
                        && rm -rf /var/lib/apt/lists/*

                    # 2. Install the native Claude Code CLI tool
                    RUN curl -fsSL https://claude.ai/install.sh | bash

                    # 3. Create a global symlink using the exact path from your install log
                    # This bypasses the $PATH profile restriction for non-interactive runners
                    RUN ln -sf /root/.local/bin/claude /usr/local/bin/claude

                    WORKDIR /app
                    CMD ["/bin/bash"]
                    EOT
        }
    }
}

step "print-report" {
    condition = "Variable"
    name = "Print Report"
    properties = {
        Octopus.Step.ConditionVariableExpression = "#{SelfSupport.RunCondition}"
    }

    action {
        action_type = "Octopus.Script"
        properties = {
            Octopus.Action.RunOnServer = "true"
            Octopus.Action.Script.ScriptBody = "Write-Highlight $OctopusParameters[\"Octopus.Action[Run Claude Agent].Output.Octopus.Action.Claude.Response\"]"
            Octopus.Action.Script.ScriptSource = "Inline"
            Octopus.Action.Script.Syntax = "PowerShell"
        }
        worker_pool_variable = "#{SelfSupport.WorkerPool}"
    }
}