📚 Cheatsheet

Une collection organisée de snippets de code pour accélérer votre développement. Parcourez, recherchez et copiez en un clic.

Snippets 10

Retour
GitLab CI - Artifacts de build
Facile
build_job:
  stage: build
  script:
    - npm run build
  artifacts:
    paths:
      - build/
GitLab CI - Cache des dépendances
Facile
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - node_modules/
GitLab CI - Inclure d'autres fichiers CI
Intermédiaire
include:
  - local: '/.gitlab-ci-templates.yml'
GitLab CI - Job manuel
Intermédiaire
deploy_prod:
  stage: deploy
  script:
    - echo "Deploying to production"
  when: manual
GitLab CI - Matrix build
Avancé
test:
  script: npm test
  parallel:
    matrix:
      - PROVIDER: aws
        STACK:
          - monitoring
          - app
      - PROVIDER: gcp
GitLab CI - Pipeline simple
Facile
stages:
  - build
  - test

build_job:
  stage: build
  script:
    - echo "Building..."

test_job:
  stage: test
  script:
    - echo "Testing..."
GitLab CI - Règles conditionnelles (rules)
Intermédiaire
deploy_job:
  stage: deploy
  script: deploy.sh
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'
GitLab CI - Utiliser des services
Avancé
test_job:
  stage: test
  services:
    - postgres:14.5
  script:
    - run_integration_tests.sh
GitLab CI - Utiliser une image Docker
Facile
default:
  image: node:18-alpine

build_job:
  script:
    - npm install
    - npm run build
GitLab CI - Variables personnalisées
Facile
variables:
  NODE_ENV: production

build_job:
  script:
    - echo "Building for $NODE_ENV"