first commit
This commit is contained in:
46
.gitignore
vendored
Executable file
46
.gitignore
vendored
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
# Created by https://www.gitignore.io/api/macos,vagrant,visualstudiocode
|
||||||
|
|
||||||
|
### macOS ###
|
||||||
|
*.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
### Vagrant ###
|
||||||
|
.vagrant/
|
||||||
|
*.box
|
||||||
|
|
||||||
|
### VisualStudioCode ###
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.history
|
||||||
|
|
||||||
|
### Ansible ###
|
||||||
|
*.retry
|
||||||
|
|
||||||
|
# End of https://www.gitignore.io/api/macos,vagrant,visualstudiocode,ansible
|
||||||
76
README.md
Executable file
76
README.md
Executable file
@@ -0,0 +1,76 @@
|
|||||||
|
[](http://www.agile611.com/)
|
||||||
|
|
||||||
|
# Agile611 Jenkins CI/CD Training
|
||||||
|
|
||||||
|
Este repositorio ofrece scripts y una configuración mínima para levantar un entorno de Jenkins de prueba local usando Vagrant.
|
||||||
|
|
||||||
|
**Objetivo:** Proporcionar un punto de partida sencillo para probar Jenkins (y opcionalmente SonarQube) en entornos locales y educativos de CI.
|
||||||
|
|
||||||
|
**Requisitos:**
|
||||||
|
- macOS, Linux o Windows con compatibilidad para Docker o Vagrant
|
||||||
|
- Permisos de ejecución para los scripts (`chmod +x *.sh`)
|
||||||
|
- **git**: Necesario para clonar el repositorio
|
||||||
|
- **Vagrant**: Este repositorio utiliza una caja Vagrant basada en Ubuntu y se utilizará APT.
|
||||||
|
- **Virtualbox**: Es el motor para virtualizar el entorno.
|
||||||
|
|
||||||
|
**Estructura del repositorio:**
|
||||||
|
- `docker.sh` — script para arrancar servicios con Docker
|
||||||
|
- `jenkins.sh` — script de ayuda para gestionar Jenkins (arrancar, detener, acceder)
|
||||||
|
- `sonarqube.sh` — script para arrancar SonarQube (opcional)
|
||||||
|
- `Vagrantfile` — definición para crear una VM con Vagrant que instala Jenkins
|
||||||
|
|
||||||
|
**Inicio rápido (Vagrant)**
|
||||||
|
|
||||||
|
1) Instala Vagrant y VirtualBox.
|
||||||
|
2) Inicia la VM definida en el `Vagrantfile`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vagrant up
|
||||||
|
vagrant ssh jenkins
|
||||||
|
# dentro de la VM, sigue las instrucciones del Vagrantfile o de los scripts
|
||||||
|
```
|
||||||
|
|
||||||
|
**Descripción breve de los scripts:**
|
||||||
|
- `docker.sh`: crea y gestiona contenedores (Jenkins, posiblemente SonarQube u otros servicios). Revisa su contenido para ajustar puertos y volúmenes.
|
||||||
|
- `jenkins.sh`: utilidades para obtener la URL de acceso, el usuario inicial y los secrets.
|
||||||
|
- `sonarqube.sh`: arranca SonarQube en modo desarrollo para escaneos locales.
|
||||||
|
- `Vagrantfile`: configura una máquina virtual con una instalación mínima para ejecutar Jenkins sin Docker.
|
||||||
|
|
||||||
|
**Puertos por defecto (configurables):**
|
||||||
|
- Jenkins: 8080
|
||||||
|
- SonarQube: 9000
|
||||||
|
|
||||||
|
## Resolución de problemas
|
||||||
|
- Si un puerto está ocupado, modifica la configuración del script o libera el puerto.
|
||||||
|
- Comprueba permisos: `chmod +x *.sh`.
|
||||||
|
- Revisa logs de los contenedores con `docker logs <container>` o entra con `vagrant ssh` y consulta los logs dentro de la VM.
|
||||||
|
|
||||||
|
## Contribuir
|
||||||
|
- Abre un issue para proponer mejoras o reportar bugs.
|
||||||
|
- Haz fork y envía pull requests con cambios pequeños y bien documentados.
|
||||||
|
|
||||||
|
## Solución de problemas
|
||||||
|
|
||||||
|
Si encuentras problemas al aprovisionar la caja, puedes descargarla directamente y añadirla a Vagrant.
|
||||||
|
|
||||||
|
## Problemas comunes de red
|
||||||
|
|
||||||
|
Si tienes proxies o VPNs activos en tu equipo, es posible que Vagrant no pueda aprovisionar el entorno.
|
||||||
|
|
||||||
|
Comprueba tu conectividad previamente.
|
||||||
|
|
||||||
|
## Licencia
|
||||||
|
|
||||||
|
Este proyecto está publicado bajo la licencia MIT. Modifica según tus necesidades.
|
||||||
|
|
||||||
|
Este tutorial ha sido publicado por [Agile611](http://www.agile611.com/) bajo la licencia Creative Commons Atribución-NoComercial 4.0 Internacional.
|
||||||
|
|
||||||
|
[](https://creativecommons.org/licenses/by-nc/4.0/)
|
||||||
|
|
||||||
|
|
||||||
|
Este `README` fue originalmente escrito por [Guillem Hernández Sola](https://www.linkedin.com/in/guillemhs/) y también se publica en el dominio público.
|
||||||
|
|
||||||
|
Contacta con Agile611 para más detalles.
|
||||||
|
- [Agile611](http://www.agile611.com/)
|
||||||
|
- Laureà Miró 309
|
||||||
|
- 08950 Esplugues de Llobregat (Barcelona)
|
||||||
28
Vagrantfile
vendored
Normal file
28
Vagrantfile
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
Vagrant.configure(2) do |config|
|
||||||
|
config.vm.define "jenkins" do |jenkins|
|
||||||
|
jenkins.vm.box = "bento/ubuntu-24.04"
|
||||||
|
jenkins.vm.network "private_network", ip: "192.168.11.11"
|
||||||
|
jenkins.vm.hostname = "jenkins"
|
||||||
|
jenkins.vm.provision :shell, :path => "jenkins.sh"
|
||||||
|
jenkins.vm.network "forwarded_port", guest: 8080, host: 8080
|
||||||
|
jenkins.vm.network "forwarded_port", guest: 50000, host: 50000
|
||||||
|
end
|
||||||
|
|
||||||
|
config.vm.define "agent" do |agent|
|
||||||
|
agent.vm.box = "bento/ubuntu-24.04"
|
||||||
|
agent.vm.network "private_network", ip: "192.168.11.13"
|
||||||
|
agent.vm.hostname = "agent"
|
||||||
|
agent.vm.provision :shell, :path => "docker.sh"
|
||||||
|
agent.vm.provision :shell, :path => "sonarqube.sh"
|
||||||
|
agent.vm.network "forwarded_port", guest: 50000, host: 50001
|
||||||
|
agent.vm.network "forwarded_port", guest: 2376, host: 2376
|
||||||
|
agent.vm.network "forwarded_port", guest: 4243, host: 4243
|
||||||
|
agent.vm.network "forwarded_port", guest: 9999, host: 9999
|
||||||
|
agent.vm.network "forwarded_port", guest: 9000, host: 9000
|
||||||
|
agent.vm.network "forwarded_port", guest: 3000, host: 3000
|
||||||
|
for i in 32770..32900
|
||||||
|
agent.vm.network :forwarded_port, guest: i, host: i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
21
docker.sh
Normal file
21
docker.sh
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -eux
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
apt-transport-https \
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
software-properties-common \
|
||||||
|
python-is-python3 zip python3-simplejson \
|
||||||
|
gnupg2 \
|
||||||
|
software-properties-common
|
||||||
|
apt-get install -y default-jre default-jdk git
|
||||||
|
|
||||||
|
curl -fsSL get.docker.com -o get-docker.sh
|
||||||
|
sh get-docker.sh
|
||||||
|
|
||||||
|
# install docker-compose
|
||||||
|
curl -L "https://github.com/docker/compose/releases/download/v2.11.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
|
||||||
|
chmod +x /usr/local/bin/docker-compose
|
||||||
|
|
||||||
|
usermod -G docker vagrant
|
||||||
40
jenkins.sh
Normal file
40
jenkins.sh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -eux
|
||||||
|
apt update
|
||||||
|
apt upgrade -y
|
||||||
|
apt install default-jdk -y
|
||||||
|
mkdir -p /usr/share/keyrings
|
||||||
|
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
|
||||||
|
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
|
||||||
|
https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
|
||||||
|
apt update
|
||||||
|
apt install jenkins -y
|
||||||
|
systemctl status jenkins --no-pager -l
|
||||||
|
sudo systemctl enable --now jenkins
|
||||||
|
|
||||||
|
# 3. Instalar Git
|
||||||
|
sudo apt-get install -y git
|
||||||
|
|
||||||
|
# 4. Instalar Terraform
|
||||||
|
sudo apt-get install -y gnupg software-properties-common
|
||||||
|
wget -O- https://apt.releases.hashicorp.com/gpg | \
|
||||||
|
gpg --dearmor | \
|
||||||
|
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null
|
||||||
|
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
|
||||||
|
https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
|
||||||
|
sudo tee /etc/apt/sources.list.d/hashicorp.list
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y terraform
|
||||||
|
|
||||||
|
# 5. Instalar Ansible
|
||||||
|
sudo add-apt-repository --yes --update ppa:ansible/ansible
|
||||||
|
sudo apt-get install -y ansible
|
||||||
|
|
||||||
|
# Iniciar Jenkins
|
||||||
|
sudo systemctl enable jenkins
|
||||||
|
sudo systemctl start jenkins
|
||||||
|
|
||||||
|
echo "¡Instalación completa! Jenkins está corriendo en el puerto 8080."
|
||||||
|
# Imprimir la contraseña inicial para facilitar el primer login
|
||||||
|
echo "La contraseña inicial de Admin es:"
|
||||||
|
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
|
||||||
8
sonarqube.sh
Normal file
8
sonarqube.sh
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -eux
|
||||||
|
apt-get update
|
||||||
|
apt-get -y install default-jre default-jdk
|
||||||
|
#wget https://downloads.sourceforge.net/project/sonar-pkg/deb/binary/sonar_6.7.4_all.deb
|
||||||
|
wget https://sourceforge.net/projects/sonar-pkg/files/deb/binary/sonar_7.1_all.deb
|
||||||
|
dpkg -i sonar_7.1_all.deb
|
||||||
|
/etc/init.d/sonar start
|
||||||
Reference in New Issue
Block a user