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