Merge pull request 'feat: refs #4409 Available by lot using CDC' (!7) from 4685-available into master
gitea/mycdc/pipeline/head There was a failure building this commit
Details
gitea/mycdc/pipeline/head There was a failure building this commit
Details
Reviewed-on: #7 Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
This commit is contained in:
commit
a1bdcf4fae
|
@ -1,33 +1,81 @@
|
|||
#!/usr/bin/env groovy
|
||||
|
||||
def PROTECTED_BRANCH
|
||||
def IS_LATEST
|
||||
|
||||
node {
|
||||
stage('Setup') {
|
||||
PROTECTED_BRANCH = [
|
||||
'dev',
|
||||
'test',
|
||||
'master',
|
||||
'main',
|
||||
'beta'
|
||||
].contains(env.BRANCH_NAME)
|
||||
|
||||
IS_LATEST = ['master', 'main'].contains(env.BRANCH_NAME)
|
||||
|
||||
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
|
||||
echo "NODE_NAME: ${env.NODE_NAME}"
|
||||
echo "WORKSPACE: ${env.WORKSPACE}"
|
||||
}
|
||||
}
|
||||
pipeline {
|
||||
agent any
|
||||
options {
|
||||
disableConcurrentBuilds()
|
||||
}
|
||||
stages {
|
||||
stage('Build') {
|
||||
when {branch 'master'}
|
||||
stage('Version') {
|
||||
when {
|
||||
expression { PROTECTED_BRANCH }
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
def packageJson = readJSON file: 'package.json'
|
||||
env.VERSION = packageJson.version
|
||||
def version = "${packageJson.version}-build${env.BUILD_ID}"
|
||||
writeFile(file: 'VERSION.txt', text: version)
|
||||
echo "VERSION: ${version}"
|
||||
}
|
||||
sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel'
|
||||
}
|
||||
}
|
||||
stage('Push') {
|
||||
when {branch 'master'}
|
||||
stage('Build') {
|
||||
when {
|
||||
expression { PROTECTED_BRANCH }
|
||||
}
|
||||
environment {
|
||||
CREDENTIALS = credentials('docker-registry')
|
||||
VERSION = readFile 'VERSION.txt'
|
||||
}
|
||||
parallel {
|
||||
stage('Producer') {
|
||||
steps {
|
||||
dockerBuild 'mycdc-producer', '.', 'assets/Dockerfile.producer'
|
||||
}
|
||||
}
|
||||
stage('Consumer') {
|
||||
steps {
|
||||
dockerBuild 'mycdc-consumer', '.', 'assets/Dockerfile.consumer'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
when {
|
||||
branch 'dev'
|
||||
branch 'test'
|
||||
}
|
||||
environment {
|
||||
VERSION = readFile 'VERSION.txt'
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
def packageJson = readJSON file: 'package.json'
|
||||
env.VERSION = packageJson.version
|
||||
withKubeConfig([
|
||||
serverUrl: "$KUBERNETES_API",
|
||||
credentialsId: 'kubernetes',
|
||||
namespace: 'mycdc'
|
||||
]) {
|
||||
sh 'kubectl set image deployment/producer-$BRANCH_NAME main=$REGISTRY/mycdc-producer:$VERSION'
|
||||
sh 'kubectl set image deployment/consumer-$BRANCH_NAME main=$REGISTRY/mycdc-consumer:$VERSION'
|
||||
}
|
||||
sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY'
|
||||
sh 'docker-compose push'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,3 +86,19 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
def dockerBuild(imageName, context, dockerfile = null) {
|
||||
if (dockerfile == null)
|
||||
dockerfile = "${context}/Dockerfile"
|
||||
def baseImage = "${imageName}:${env.VERSION}"
|
||||
def image = docker.build(baseImage, "-f ${dockerfile} ${context}")
|
||||
dockerPush(image)
|
||||
}
|
||||
|
||||
def dockerPush(image) {
|
||||
docker.withRegistry("https://${env.REGISTRY}", 'docker-registry') {
|
||||
image.push()
|
||||
image.push(env.BRANCH_NAME)
|
||||
if (IS_LATEST) image.push('latest')
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,4 +50,4 @@ npm run consumer
|
|||
|
||||
* [Zongji](https://github.com/nevill/zongji)
|
||||
* [MySQL2](https://github.com/sidorares/node-mysql2#readme)
|
||||
* [RabbitMQ] (https://www.rabbitmq.com/)
|
||||
* [RabbitMQ](https://www.rabbitmq.com/)
|
||||
|
|
|
@ -9,5 +9,3 @@ CREATE TABLE `util`.`binlogQueue`(
|
|||
CREATE USER 'mycdc-producer'@'%' IDENTIFIED BY 'P4$$w0rd';
|
||||
GRANT REPLICATION SLAVE, REPLICATION CLIENT, SELECT ON *.* TO 'mycdc-producer'@'%';
|
||||
GRANT INSERT, DELETE ON `util`.* TO 'mycdc-producer'@'%';
|
||||
|
||||
CREATE USER 'mycdc-producer'@'%' IDENTIFIED BY 'P4$$w0rd';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mycdc",
|
||||
"version": "0.0.24",
|
||||
"version": "0.0.25",
|
||||
"author": "Verdnatura Levante SL",
|
||||
"description": "Asynchronous DB calculations reading the binary log",
|
||||
"license": "GPL-3.0",
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
query:
|
||||
travel: CALL stock.buyOut_refreshBuy('travel', :id)
|
||||
entry: CALL stock.buyOut_refreshBuy('entry', :id)
|
||||
buy: CALL stock.buyOut_refreshBuy('lot', :id)
|
||||
ticket: CALL stock.buyOut_refreshSale('ticket', :id)
|
||||
sale: CALL stock.buyOut_refreshSale('lot', :id)
|
||||
order: CALL stock.buyOut_refreshOrder('order', :id)
|
||||
orderRow: CALL stock.buyOut_refreshOrder('lot', :id)
|
||||
includeSchema:
|
||||
vn:
|
||||
travel:
|
||||
key: id
|
||||
columns:
|
||||
- id
|
||||
- landed
|
||||
- shipped
|
||||
- landingHour
|
||||
- warehouseInFk
|
||||
- warehouseOutFk
|
||||
- isReceived
|
||||
- isRaid
|
||||
events:
|
||||
- updaterows
|
||||
entry:
|
||||
key: id
|
||||
columns:
|
||||
- id
|
||||
- travelFk
|
||||
events:
|
||||
- updaterows
|
||||
buy:
|
||||
key: lotFk
|
||||
columns:
|
||||
- lotFk
|
||||
- entryFk
|
||||
- itemFk
|
||||
- quantity
|
||||
- life
|
||||
- isAlive
|
||||
ticket:
|
||||
key: id
|
||||
columns:
|
||||
- id
|
||||
- warehouseFk
|
||||
- shipped
|
||||
- landed
|
||||
- isAlive
|
||||
events:
|
||||
- updaterows
|
||||
sale:
|
||||
key: lotFk
|
||||
columns:
|
||||
- lotFk
|
||||
- ticketFk
|
||||
- itemFk
|
||||
- quantity
|
||||
- created
|
||||
- isPicked
|
||||
hedera:
|
||||
order:
|
||||
key: id
|
||||
columns:
|
||||
- id
|
||||
- date_send
|
||||
- address_id
|
||||
- company_id
|
||||
- customer_id
|
||||
- confirmed
|
||||
events:
|
||||
- updaterows
|
||||
orderRow:
|
||||
key: lotFk
|
||||
columns:
|
||||
- lotFk
|
||||
- orderFk
|
||||
- itemFk
|
||||
- warehouseFk
|
||||
- shipment
|
||||
- amount
|
||||
- created
|
||||
- isReserved
|
Loading…
Reference in New Issue