ABJ Informática
Home ADS
00:00:00

GitLab — Repositório, Runner e CI/CD

GitLab — Repositório, Runner e CI/CD

Plataforma DevOps completa — versionamento Git, merge requests, automação com GitLab Runner e pipelines declaradas em .gitlab-ci.yml.

O que é GitLab

Componentes da arquitetura

Instalação do GitLab Runner

Configurando uma pipeline CI/CD

Exemplo visual — fluxo GitLab CI/CD

Figura 1 — GitLab Server, Runner e pipeline do projeto abjinfo.com.br.

Boas práticas

Modelo textual — instalação runner + .gitlab-ci.yml

────────────────────────────────────────────────────────────
GITLAB RUNNER + CI/CD — ROTEIRO DE CONFIGURAÇÃO
────────────────────────────────────────────────────────────

1. CRIAR RUNNER NO GITLAB
   Projeto → Settings → CI/CD → Runners → New project runner
   SO: Windows | Tags: windows | Executor: shell

2. INSTALAR RUNNER (Windows — PowerShell admin)
   mkdir C:\GitLab-Runner
   # Baixar gitlab-runner.exe para C:\GitLab-Runner
   cd C:\GitLab-Runner
   .\gitlab-runner register
     URL:      https://gitlab.seudominio.com.br/
     Token:    [token gerado na UI]
     Tags:     windows
     Executor: shell
   .\gitlab-runner install
   .\gitlab-runner start

3. VARIÁVEIS CI/CD (Settings → CI/CD → Variables)
   SSH_HOST        (masked)
   SSH_USER        (masked)
   SSH_PASSWORD    (masked, protected)
   DEPLOY_PATH     ex.: /var/www/abjinfo.com.br
   WINSCP_PATH     opcional — caminho do WinSCP.com

4. ARQUIVO .gitlab-ci.yml (raiz do repositório)
────────────────────────────────────────────────────────────
stages:
  - validate
  - deploy

default:
  tags:
    - windows

validate_page:
  stage: validate
  script:
    - if (-not (Test-Path "index.php")) { throw "index.php nao encontrado" }
    - if (-not (Test-Path ".htaccess")) { throw ".htaccess nao encontrado" }

deploy_sftp:
  stage: deploy
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'
  script:
    - # sincronizar via WinSCP/SFTP para $env:DEPLOY_PATH
────────────────────────────────────────────────────────────

5. CHECKLIST ANTES DO PRIMEIRO DEPLOY
  [ ] Runner online (verde) com tag windows
  [ ] Variáveis preenchidas e protegidas
  [ ] Branch main protegida (MR + pipeline obrigatória)
  [ ] Teste manual: CI/CD → Run pipeline na branch test-deploy
  [ ] Deploy em main validado; rollback = redeploy commit anterior

Vídeo — Pipeline CI/CD com GitLab

Live em português: versionamento, automação de entrega e integração com GitLab CI/CD.

Abrir no YouTube
← Voltar aos tópicos