Skip to content

Commit

Permalink
cambiando todo otra vez de red
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinoSanchez00 committed Dec 27, 2024
1 parent 7320f2d commit acd3f5c
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions jenkins/subir-Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
pipeline {
agent any
agent {
kubernetes {
label 'docker' // Usamos el agente con Docker preinstalado
defaultContainer 'docker'
}
}
environment {
APIKEY = credentials('IBM_CLOUD_API_KEY_VSANCHEZ') // Define la credencial en Jenkins previamente
}
parameters {
string(name: 'MICROSERVICE', defaultValue: 'frontend', description: 'Nombre del microservicio (frontend/backend)')
string(name: 'ENVIRONMENT', defaultValue: 'develop', description: 'Ambiente de despliegue (develop/production)')
}
stages {
stage('Determinar Ambiente') {
stage('Mostrar Configuración') {
steps {
script {
if (env.BRANCH_NAME == 'main') {
env.ENVIRONMENT = 'production'
} else {
env.ENVIRONMENT = 'develop'
}
echo "Ambiente configurado: ${env.ENVIRONMENT}"
}
echo "Configuración elegida:"
echo "Microservicio: ${params.MICROSERVICE}"
echo "Ambiente: ${params.ENVIRONMENT}"
}
}
stage('Test Frontend') {
when {
allOf {
expression { params.MICROSERVICE == 'frontend' }
branch 'main'
expression { params.ENVIRONMENT == 'production' }
}
}
steps {
Expand Down Expand Up @@ -59,10 +60,11 @@ pipeline {
stage('Instalar Herramientas') {
steps {
sh """
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
curl -sL https://aka.ms/InstallAzureCLIDeb | bash
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
ibmcloud plugin install container-registry -r 'IBM Cloud'
ibmcloud plugin install container-service -r 'IBM Cloud'
apt update && apt upgrade -y
"""
}
}
Expand All @@ -72,6 +74,7 @@ pipeline {
ibmcloud login --apikey ${APIKEY} -r eu-gb
ibmcloud target -g Stemdo_Sandbox
ibmcloud cr login
ibmcloud cr namespace-add cr-vsanchez
"""
}
}
Expand All @@ -95,20 +98,20 @@ pipeline {
}
stage('Construir Imagen') {
steps {
sh "docker build -t imagen-proyecto-${params.MICROSERVICE}-${env.ENVIRONMENT} ."
sh "docker build -t imagen-proyecto-${params.MICROSERVICE}-${params.ENVIRONMENT} ."
}
}
stage('Taggear Imagen') {
steps {
sh """
docker tag imagen-proyecto-${params.MICROSERVICE}-${env.ENVIRONMENT} uk.icr.io/cr-vsanchez/imagen-proyecto-${params.MICROSERVICE}-${env.ENVIRONMENT}:${env.VERSION}
docker tag imagen-proyecto-${params.MICROSERVICE}-${params.ENVIRONMENT} uk.icr.io/cr-vsanchez/imagen-proyecto-${params.MICROSERVICE}-${params.ENVIRONMENT}:${env.VERSION}
"""
}
}
stage('Pushear Imagen') {
steps {
sh """
docker push uk.icr.io/cr-vsanchez/imagen-proyecto-${params.MICROSERVICE}-${env.ENVIRONMENT}:${env.VERSION}
docker push uk.icr.io/cr-vsanchez/imagen-proyecto-${params.MICROSERVICE}-${params.ENVIRONMENT}:${env.VERSION}
"""
}
}
Expand Down

0 comments on commit acd3f5c

Please sign in to comment.