This commit is contained in:
Marco Santos
2025-01-06 10:29:50 +00:00
parent 1992845153
commit fcfd47d8b1

36
Jenkinsfile vendored
View File

@@ -1,3 +1,4 @@
pipeline {
agent any
@@ -10,6 +11,7 @@ pipeline {
pollSCM('* * * * *')
}
/*
environment {
now = new Date().format('yyyyMMdd-HHmm', TimeZone.getTimeZone('UTC'))
DOCKER_HOST = 'tcp://192.168.2.20:2375'
@@ -17,11 +19,21 @@ pipeline {
DOCKER_REGISTRY = 'Shini89' //'your-docker-registry.com' // Registro Docker
REACT_DIR = 'geradoresfe'
REACT_DOCKER_IMAGE = 'geradoresfe:lastest'
REACT_DOCKER_IMAGE = 'shini89/geradoresfe:lastest'
SERVICE_DIR = 'GeradoresService'
API_DIR = 'GeradoresWS'
API_DOCKER_IMAGE = 'geradoresws:lastest'
API_DOCKER_IMAGE = 'shini89/geradoresws:lastest'
}
*/
environment {
DOCKER_HOST = 'tcp://192.168.2.20:2375'
DOCKER_REGISTRY = 'docker.io/shini89'
DOCKER_TAG = "${env.BUILD_ID}" // Tag única para builds
REACT_DIR = 'geradoresfe'
SERVICE_DIR = 'GeradoresService'
API_DIR = 'GeradoresWS'
}
stages {
@@ -30,7 +42,7 @@ pipeline {
script {
echo "Validando conexão com Docker remoto: ${DOCKER_HOST}"
// Testa a conexão com o Docker remoto
sh "docker info"
sh 'docker --version'
}
}
}
@@ -86,9 +98,10 @@ pipeline {
stage('Build WS Docker Image') {
steps {
// Construir a imagem Docker do Backend usando o Dockerfile existente
script {
docker.build("${API_DOCKER_IMAGE}", "-t shini89/homeware:lastest -f ${API_DIR}/Dockerfile .")
dir("${env.API_DIR}") {
script {
docker.build("${DOCKER_REGISTRY}/geradoresws:${DOCKER_TAG}", '.')
}
}
}
}
@@ -112,7 +125,7 @@ pipeline {
steps {
dir("${env.REACT_DIR}") {
script {
docker.build("${env.REACT_DOCKER_IMAGE}", ".")
docker.build("${DOCKER_REGISTRY}/geradoresfe:${DOCKER_TAG}", ".")
}
}
}
@@ -121,11 +134,10 @@ pipeline {
stage('Push Docker Images') {
steps {
script {
// Fazer login no Docker Hub (ou outro registro Docker)
sh 'docker login -u shini89 -p Spongebob!1'
// Publicar as imagens
sh "docker push shini89/homeware:latest"
docker.withRegistry('https://index.docker.io/v1/', 'docker-credentials') {
docker.image("${DOCKER_REGISTRY}/geradoresws:${DOCKER_TAG}").push()
docker.image("${DOCKER_REGISTRY}/geradoresfe:${DOCKER_TAG}").push()
}
}
}
}