pipeline
This commit is contained in:
46
piepeline
Normal file
46
piepeline
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
environment {
|
||||||
|
TERRAFORM_HOME = tool 'Terraform' // Define la herramienta Terraform como una variable de entorno
|
||||||
|
PROJECT_DIR = 'ruta_del_proyecto'
|
||||||
|
CLOUDGURU_API_KEY = credentials('cloudguru-api-key') // Almacena la clave de la API de CloudGuru en Jenkins Credentials
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Clonar Repositorio') {
|
||||||
|
steps {
|
||||||
|
checkout scm
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Configurar Infraestructura con Terraform') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
sh "${TERRAFORM_HOME}/terraform init ${PROJECT_DIR}"
|
||||||
|
sh "${TERRAFORM_HOME}/terraform apply -auto-approve ${PROJECT_DIR}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Desplegar Laboratorio') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
// Llamadas a la API de CloudGuru para configurar el laboratorio
|
||||||
|
withCredentials([string(credentialsId: 'cloudguru-api-key', variable: 'CLOUDGURU_API_KEY')]) {
|
||||||
|
sh "curl -X POST -H 'Authorization: Bearer ${CLOUDGURU_API_KEY}' https://api.cloudguru.com/labs/deploy"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
echo 'Pipeline ejecutado exitosamente.'
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
echo 'Error en la ejecución del pipeline.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user