Gitlab CI
Gitlab CI
Gitlab CI
jobs, que definen qué hacer. Por ejemplo, trabajos que compilan o prueban código.
stages, que definen cuándo ejecutar los trabajos. Por ejemplo, etapas que ejecutan
pruebas después de etapas que compilan el código.
La configuración del pipeline comienza con los jobs. Los jobs son el elemento más
fundamental de un archivo .gitlab-ci.yml.
● Definido con restricciones que indican bajo qué condiciones deben ejecutarse.
● Elementos de nivel superior con un nombre arbitrario y deben contener al menos la
cláusula del script.
● No está limitado en cuántos se pueden definir.
image: centos:7
test:
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
image: centos:7
test:
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
image: centos:7
test:
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
image: centos:7
test:
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
image: centos:7
test:
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
Creación de test:
test:
script:
script:
pipeline - echo "Hello, $GITLAB_USER_LOGIN!"
- echo "Hello, $GITLAB_USER_LOGIN!"
2. Revisar el pipeline.
5 minutos
3. Revisar la salida de la consola.
Lección 3 - Proyecto 16
Gitlab pipelines - ¿Cómo funciona gitlab runner?
21
¿Qué es Docker?
Usa rules para incluir o excluir jobs del pipeline de acuerdo al evente
test: test:
Creación de script: script:
- echo -"Hello, $GITLAB_USER_LOGIN!"
echo "Hello, $GITLAB_USER_LOGIN!"
pipeline con rules:
- if: '$CI_COMMIT_BRANCH == "develop"'
regla when: always
image: centos:7
test:
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
- yum update -y
- yum install -y python3
- python3 test_calculator.py
5 minutos
2. Revisar el pipeline.
3. Revisar la salida de la consola.
Lección 3 - Proyecto 34
Gitlab pipelines - Pipeline para pruebas con python
.gitlab-ci.yml .gitlab-ci.yml
test: test:
script: script:
- echo "Hello, $GITLAB_USER_LOGIN!" - echo "Hello, $GITLAB_USER_LOGIN!"
- yum update -y - python3 test_calculator.py
- yum install -y python3
- python3 test_calculator.py
before_script:
- pip install flake8
stages:
.gitlab-ci.yml - linter
- test
linter:
stage: linter
script:
- flake8 calculator.py
test:
stage: test
script:
- python3 test_calculator.py
test: stages:
Creación de script: - linter
- test
- echo "Hello, $GITLAB_USER_LOGIN!"
pipeline 2 linter:
stage: linter
script:
- flake8 calculator.py
test:
stage: test
script:
5 minutos - python3 test_calculator.py
2. Revisar el pipeline.
3. Revisar la salida de la consola.
Lección 3 - Proyecto 38
Gitlab pipelines - Pipeline para pruebas con python
Ejecución paralelo image: python:3
before_script:
- pip install flake8
stages:
- linter
.gitlab-ci.yml - test
linter:
stage: linter
script:
- flake8 calculator.py
test:
stage: test
script:
- python3 test_calculator.py
message:
stage: test
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
stages:
test: - linter
pipeline
stage: linter
script:
- flake8 calculator.py
paralelo test:
stage: test
script:
- python3 test_calculator.py
5 minutos message:
stage: test
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
2. Revisar el pipeline.
3. Revisar la salida de la consola.
Lección 3 - Proyecto 41
Job artifacts
before_script:
- pip install flake8
- pip install pytest pytest-html
stages:
.gitlab-ci.yml - linter
- test
linter:
stage: linter
script:
- flake8 calculator.py
test:
stage: test
script:
- pytest --html=report.html
artifacts:
paths:
- report.html
- assets/
stages:
test:
Creación de script:
- linter
- test
artefactos test:
stage: test
script:
- pytest --html=report.html
artifacts:
5 minutos paths:
- report.html
- assets/
2. Revisar el pipeline.
3. Descargar los archivos del pipeline
Lección 3 - Proyecto 45
Variables de pipelines
Las variables CI/CD son un tipo de variable de entorno. Puedes usarlos para:
before_script:
- pip install flake8
- pip install pytest pytest-html
stages:
- linter
- test Gitlab pipelines - Ejecución con variables
linter:
stage: linter
script:
.gitlab-ci.yml
- flake8 calculator.py
test:
stage: test
script:
- pytest --html=report.html
artifacts:
paths:
- report.html
- assets/
message:
stage: test
script:
- echo "PRE, $PASSWORD_PRE! and $URL_PRE"
Lección 3 - Proyecto 51
Gitlab pipelines - Docker images
image: python:3
before_script:
- pip install flake8
- pip install pytest pytest-html
message:
stage: test
script:
- echo "PRE, $PASSWORD_PRE! and $URL_PRE"
image: python:3
before_script:
- pip install flake8
- pip install pytest pytest-html
message:
stage: test
script:
- echo "PRE, $PASSWORD_PRE! and $URL_PRE"
image: mcr.microsoft.com/dotnet/sdk:latest
message:
stage: test
script:
- echo "Version dotnet installed"
- dotnet --version
.gitlab-ci.yml
tests:
stage: test
script:
- 'dotnet test --no-restore'
message:
stage: test
Pipeline con script:
- echo "Version dotnet installed"
docker image - dotnet --version
Lección 3 - Proyecto 57
Gitlab pipelines Node js
Usando la herramienta npm se
.gitlab-ci.yml puede hacer build, test, publish, etc.
image: node:latest
message:
stage: test
script:
- echo "Version nodjs installed"
- node -v
- npm -v
.gitlab-ci.yml
message:
stage: test
Pipeline con script:
- echo "Version nodjs installed"
docker image - node -v
- npm -v
Lección 3 - Proyecto 60
1. Realizar un proyecto usando otro lenguaje de
programación que no sea python. No se requiere
Práctica 20 la interfaz gráfica, puede realizar la funcionalidad
Lección 3 - Proyecto 61