Testing Gitlab Self Hosted Instances

how-to do diagnostic using gitlab-ci.yml ?



# Basic diagnostic for GitLab Self-hosted
stages:
  - diagnostic

diagnostic:
  stage: diagnostic
  script:
    - echo "GitLab Self-hosted Diagnostic"
    
    # Checking the status of GitLab services
    - echo "1. Checking the status of GitLab services..."
    - sudo gitlab-ctl status || echo "Error checking GitLab services."

    # Checking the GitLab version
    - echo "2. Checking GitLab version..."
    - sudo gitlab-rake gitlab:env:info || echo "Error fetching GitLab version."

    # Checking the integrity of database migrations
    - echo "3. Checking migration integrity..."
    - sudo gitlab-rake db:migrate:status || echo "Error checking migration status."

    # Checking disk usage
    - echo "4. Checking disk usage..."
    - df -h || echo "Error checking disk usage."

    # Checking memory and CPU usage
    - echo "5. Checking memory and CPU usage..."
    - free -m || echo "Error checking memory usage."
    - top -b -n 1 | head -n 10 || echo "Error fetching CPU usage."

    # Checking for errors in logs
    - echo "6. Checking recent errors in logs..."
    - sudo tail -n 100 /var/log/gitlab/gitlab-rails/production.log || echo "Error fetching production logs."

    # Checking network connectivity (optional)
    - echo "7. Checking network connectivity (ping to google.com)..."
    - ping -c 4 google.com || echo "Network connectivity issue."

    # General GitLab diagnostic (collects detailed information)
    - echo "8. Running gitlab-rake gitlab:check..."
    - sudo gitlab-rake gitlab:check || echo "Error running gitlab:check."

    # Completion
    - echo "Diagnostic completed."
1 Like