Skip to content

Main #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Main #102

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 98 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,102 @@
# simple-python-pyinstaller-app
# Guía de Despliegue: Aplicación Python con Jenkins y Terraform

This repository is for the
[Build a Python app with PyInstaller](https://jenkins.io/doc/tutorials/build-a-python-app-with-pyinstaller/)
tutorial in the [Jenkins User Documentation](https://jenkins.io/doc/).
Este documento guía paso a paso el despliegue de una aplicación Python utilizando Jenkins como servidor de integración continua y Terraform para la infraestructura.

The repository contains a simple Python application which is a command line tool "add2vals" that outputs the addition of two values. If at least one of the
values is a string, "add2vals" treats both values as a string and instead
concatenates the values. The "add2" function in the "calc" library (which
"add2vals" imports) is accompanied by a set of unit tests. These are tested with pytest to check that this function works as expected and the results are saved
to a JUnit XML report.
---

The delivery of the "add2vals" tool through PyInstaller converts this tool into
a standalone executable file for Linux, which you can download through Jenkins
and execute at the command line on Linux machines without Python.
## Requisitos Previos

- Docker y Docker Compose instalados.
- Terraform instalado.
- Cuenta de GitHub con el repositorio forkeado.
- Acceso a puerto `8080` en tu máquina local

---

## 1. Preparación del Repositorio

### Fork y Configuración Inicial

1. Realiza un *fork* del repositorio `simple-python-pyinstaller-app` en tu cuenta de GitHub.
2. Renombra la rama principal a `main` si es necesario.

---

## 2. Construcción de Imagen Jenkins Personalizada

### Crear Dockerfile

En el directorio `/docs`, crea un archivo `Dockerfile` con las dependencias necesarias para Jenkins y Blue Ocean.

### Construir la Imagen

Desde la misma carpeta `/docs`, ejecuta:

```bash
docker build -t myjenkins-blueocean .
```
## 3. Despliegue de Infraestructura con Terraform

### Archivo de Configuración

Crea un archivo llamado `main.tf` en la carpeta `/docs` con tu configuración deseada.

### Comandos para Inicializar y Aplicar
```bash
terraform init
terraform plan
terraform apply
```
Esto levantará la infraestructura necesaria para Jenkins.
## 4. Configuración de Jenkins

### Acceder al Panel Web

Abre el navegador y entra a:

`http://localhost:8080`

### Obtener la Contraseña de Desbloqueo

Ejecuta:


`docker logs jenkins-blueocean`

Copia la contraseña que aparece en consola e introdúcela en la interfaz web para completar la configuración inicial.
## 5. Crear el Pipeline

### Nuevo Proyecto

1. Haz clic en `New item` desde el panel de Jenkins.

2. Asigna un nombre y selecciona `Pipeline`.

3. Activa la opción `SCM Polling` para habilitar la ejecución automática.

4. Configura el origen del script:

- SCM: `GIT`

- URL del repositorio:

- Rama: `*/main`

- Ruta al Jenkinsfile: `docs/jenkinsfile`

## 6. Ejecutar el Pipeline

1. Desde Jenkins, inicia el pipeline manualmente o espera a que detecte cambios.

2. El pipeline ejecutará automáticamente las siguientes etapas:

- **Build**

- **Test**

- **Deliver**

## 7. Verificar el Artefacto Generado

Si la ejecución es exitosa, el artefacto `add2vals` será generado y almacenado.

The `jenkins` directory contains an example of the `Jenkinsfile` (i.e. Pipeline)
you'll be creating yourself during the tutorial.
3 changes: 3 additions & 0 deletions Rama_y_nombre.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Repositorio: https://github.com/Alvarogm15/simple-python-pyinstaller-app/tree/main

Álvaro Griñon Martínez
23 changes: 23 additions & 0 deletions docs/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading