Skip to content

GitHub Enterprise

Connect Code Search to your GitHub Enterprise Server instance.

  • GitHub Enterprise Server 3.0 or later
  • A user account with access to repositories
  • A Personal Access Token
  1. Go to your GitHub Enterprise instance

  2. Navigate to Settings → Developer Settings → Personal Access Tokens → Tokens (classic)

  3. Click Generate new token (classic)

  4. Configure the token:

    • Name: Code Search
    • Expiration: Choose based on your security policy
    • Scopes: Select repo and optionally read:org
  5. Click Generate token

  6. Copy the token immediately

  1. Go to ConnectionsAdd Connection
  2. Fill in:
    • Name: GitHub Enterprise
    • Type: GitHub Enterprise
    • URL: https://github.yourcompany.com/api/v3
    • Token: Your Personal Access Token
  3. Click Test Connection
  4. Click Create
Terminal window
curl -X POST "http://localhost:8080/api/v1/connections" \
-H "Content-Type: application/json" \
-d '{
"name": "GitHub Enterprise",
"type": "github_enterprise",
"url": "https://github.yourcompany.com/api/v3",
"token": "ghp_xxxxxxxxxxxx"
}'

Add code hosts to your config.yaml:

codehosts:
# The key is the connection name
github-enterprise:
type: github_enterprise
url: "https://github.yourcompany.com"
token: "$CS_GHE_TOKEN" # Environment variable reference
exclude_archived: false # Include archived repos
Instance TypeConfig URL
github.com(use type: github instead)
GitHub Enterprisehttps://[hostname]

Examples:

  • https://github.mycompany.com
  • https://ghe.internal.example.com

If your GitHub Enterprise uses a self-signed certificate:

config.yaml
codehosts:
- name: "GitHub Enterprise"
type: "github_enterprise"
url: "https://github.yourcompany.com/api/v3"
tls:
insecure_skip_verify: false # Not recommended
ca_cert_path: "/path/to/ca-cert.pem"

Or via environment:

Terminal window
export CS_TLS_CA_CERT="/path/to/ca-cert.pem"

If using a private Certificate Authority:

  1. Add the CA certificate to the Code Search container
  2. Configure the CA cert path in configuration

Docker Compose:

services:
api:
volumes:
- ./ca-cert.pem:/etc/ssl/certs/custom-ca.pem:ro
environment:
CS_TLS_CA_CERT: /etc/ssl/certs/custom-ca.pem

Code Search uses Personal Access Tokens, which work with any GitHub Enterprise authentication method (LDAP, SAML, etc.).

GitHub Enterprise may have different repository visibility options:

  • Public (visible to everyone on the instance)
  • Internal (visible to all organization members)
  • Private (visible only to repository members)

Code Search can index all repositories the token has access to.

If your organization restricts third-party access:

  1. An admin may need to approve the token
  2. Check organization settings for OAuth/token policies

Same as standard GitHub:

ScopePurpose
repoAccess repositories
read:orgAccess organization repositories
connection refused
  • Verify the URL is correct
  • Check network connectivity to GitHub Enterprise
  • Ensure the API endpoint is accessible from Code Search
x509: certificate signed by unknown authority
  • Add your CA certificate to the trusted certificates
  • Or (not recommended) set insecure_skip_verify: true
403 Forbidden: Must have admin rights
  • Some endpoints require admin access
  • Verify the token has sufficient permissions
  • Check if the repository requires admin approval for tokens
403 Forbidden: Resource protected by SAML
  • The token needs to be authorized for SAML
  • Go to your GitHub Enterprise profile settings
  • Authorize the token for SSO

For GitHub Enterprise HA deployments:

  • Use the primary node URL
  • Code Search will follow redirects to replicas if needed