Compare commits

...

23 Commits

Author SHA1 Message Date
Robert Ferrús 826c8ff682 Merge branch 'dev' into 6371-limpiezaTablasVn2008Part1
gitea/salix/pipeline/head This commit looks good Details
2024-01-31 06:04:30 +00:00
Juan Ferrer 6d01164fb3 build: refs #6706 hook test
gitea/salix/pipeline/head This commit looks good Details
2024-01-30 23:25:14 +01:00
Juan Ferrer 827586ebd6 build: refs #6706 hook test
gitea/salix/pipeline/head Build started... Details
2024-01-30 23:14:51 +01:00
Juan Ferrer 67db31e39b build: refs #6706 hook test 2024-01-30 23:06:12 +01:00
Juan Ferrer e4f62e4e06 build: refs #6706 hook test
gitea/salix/pipeline/head This commit looks good Details
2024-01-30 22:53:33 +01:00
Juan Ferrer 53ac10d0be build: refs #6706 hook test 2024-01-30 22:33:55 +01:00
Juan Ferrer 7ab11543ed build: refs #5483 Jenkinsfile optimized for daily DB push
gitea/salix/pipeline/head This commit looks good Details
2024-01-30 21:57:04 +01:00
Juan Ferrer 420398260f fix: refs #5483 Jenkinsfile codefix
gitea/salix/pipeline/head This commit looks good Details
2024-01-30 21:49:58 +01:00
Juan Ferrer 4d065a2f79 fix: refs #5483 Jenkinsfile fixes, global nodejs tool
gitea/salix/pipeline/head This commit looks good Details
2024-01-30 21:37:20 +01:00
Juan Ferrer 4251f29a17 fix: refs #5483 compose fixes
gitea/salix/pipeline/head This commit looks good Details
2024-01-30 21:05:59 +01:00
Juan Ferrer 76545cd1ac fix: refs #5483 Jenkinsfile & compose fixes
gitea/salix/pipeline/head There was a failure building this commit Details
2024-01-30 20:58:15 +01:00
Juan Ferrer 29634e16e5 fix: refs #5483 Jenkinsfile fix
gitea/salix/pipeline/head There was a failure building this commit Details
2024-01-30 20:44:33 +01:00
Juan Ferrer 027f7d2c1d build: refs #5483 dev deploy, tag image with version
gitea/salix/pipeline/head There was a failure building this commit Details
2024-01-30 20:41:24 +01:00
Juan Ferrer 7d2b5fbeda build: refs #5483 Parallel install, code reorder
gitea/salix/pipeline/head This commit looks good Details
2024-01-30 20:04:32 +01:00
Juan Ferrer 1a64126655 build: refs #5483 Jenkinsfile parallel deploy
gitea/salix/pipeline/head This commit looks good Details
2024-01-30 19:51:30 +01:00
Juan Ferrer 3e0ebc0f26 fix: refs #5483 Jenkinsfile rocketchat fixes
gitea/salix/pipeline/head This commit looks good Details
2024-01-30 19:45:37 +01:00
Juan Ferrer 84961dda49 build: refs #5483 test workers increased to 6, test rocket notification
gitea/salix/pipeline/head There was a failure building this commit Details
2024-01-30 19:41:09 +01:00
Juan Ferrer 095d6b4140 fix: refs #5483 Unused code removed
gitea/salix/pipeline/head This commit looks good Details
2024-01-30 19:35:23 +01:00
Juan Ferrer 17c9054155 fix: refs #5483 Jenkinsfile fixes
gitea/salix/pipeline/head This commit looks good Details
2024-01-30 19:30:26 +01:00
Juan Ferrer 624f61465a fix: refs #5483 Jenkinsfile fixes
gitea/salix/pipeline/head This commit looks good Details
2024-01-30 19:05:55 +01:00
Juan Ferrer 12af757929 refs #5483 Jenkinsfile fix
gitea/salix/pipeline/head There was a failure building this commit Details
2024-01-30 19:01:14 +01:00
Juan Ferrer 79f509ca46 fix: refs #5483 Jenkinsfile code fix
gitea/salix/pipeline/head There was a failure building this commit Details
2024-01-30 18:54:41 +01:00
Juan Ferrer 56ac47dc16 build: refs #5483 send rocket message, skip steps when run source isn't git
gitea/salix/pipeline/head There was a failure building this commit Details
2024-01-30 18:52:31 +01:00
3 changed files with 113 additions and 74 deletions

181
Jenkinsfile vendored
View File

@ -1,36 +1,57 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
def PROTECTED_BRANCH
def FROM_GIT
def RUN_TESTS
pipeline { pipeline {
agent any agent any
options { options {
disableConcurrentBuilds() disableConcurrentBuilds()
} }
tools {
nodejs 'node-v20'
}
environment { environment {
PROJECT_NAME = 'salix' PROJECT_NAME = 'salix'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
} }
stages { stages {
stage('Checkout') { stage('Checkout') {
steps { steps {
script { script {
switch (env.BRANCH_NAME) { switch (env.BRANCH_NAME) {
case 'master': case 'dev':
env.NODE_ENV = 'production' env.NODE_ENV = 'dev'
env.BACK_REPLICAS = 4 env.BACK_REPLICAS = 1
break break
case 'test': case 'test':
env.NODE_ENV = 'test' env.NODE_ENV = 'test'
env.BACK_REPLICAS = 2 env.BACK_REPLICAS = 2
break break
case 'master':
env.NODE_ENV = 'production'
env.BACK_REPLICAS = 4
break
} }
}
configFileProvider([ def packageJson = readJSON file: 'package.json'
configFile(fileId: "salix.groovy", env.VERSION = packageJson.version
variable: 'GROOVY_FILE')
]) {
load env.GROOVY_FILE
}
env.GIT_COMMIT_MSG = sh(
script: 'git log -1 --pretty=%B ${GIT_COMMIT}',
returnStdout: true
).trim()
PROTECTED_BRANCH = [
'dev',
'test',
'master'
].contains(env.BRANCH_NAME)
FROM_GIT = JOB_NAME.startsWith('gitea/')
RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT
}
setEnv() setEnv()
} }
} }
@ -38,83 +59,91 @@ pipeline {
environment { environment {
NODE_ENV = "" NODE_ENV = ""
} }
steps { parallel {
nodejs('node-v20') { stage('Backend') {
sh 'npm install --no-audit --prefer-offline' steps {
sh 'gulp install --ci' sh 'npm install --no-audit --prefer-offline'
}
}
stage('Frontend') {
when {
expression { return FROM_GIT }
}
steps {
sh 'npm install --no-audit --prefer-offline --prefix=front'
}
}
stage('Print') {
when {
expression { return FROM_GIT }
}
steps {
sh 'npm install --no-audit --prefer-offline --prefix=print'
}
} }
} }
} }
stage('Test') { stage('Test') {
when { not { anyOf { when {
branch 'test' expression { return RUN_TESTS }
branch 'master' }
}}}
environment { environment {
NODE_ENV = "" NODE_ENV = ""
TZ = 'Europe/Madrid' TZ = 'Europe/Madrid'
} }
parallel { parallel {
stage('Frontend') {
steps {
nodejs('node-v20') {
sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=4'
}
}
}
stage('Backend') { stage('Backend') {
steps { steps {
nodejs('node-v20') { sh 'npm run test:back:ci'
sh 'npm run test:back:ci' }
} }
stage('Frontend') {
steps {
sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=6'
} }
} }
} }
} }
stage('Build') { stage('Build') {
when { anyOf { when {
branch 'test' expression { return PROTECTED_BRANCH && FROM_GIT }
branch 'master' }
}}
environment { environment {
CREDENTIALS = credentials('docker-registry') CREDENTIALS = credentials('docker-registry')
} }
steps { steps {
nodejs('node-v20') { sh 'gulp build'
sh 'gulp build'
}
dockerBuild() dockerBuild()
} }
} }
stage('Deploy') { stage('Deploy') {
when { anyOf { when {
branch 'test' expression { return PROTECTED_BRANCH }
branch 'master'
}}
environment {
DOCKER_HOST = "${env.SWARM_HOST}"
} }
steps { parallel {
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}" stage('Database') {
} steps {
} configFileProvider([
stage('Database') { configFile(fileId: "config.${env.NODE_ENV}.ini",
when { anyOf { variable: 'MYSQL_CONFIG')
branch 'dev' ]) {
branch 'test' sh 'mkdir -p db/remotes'
branch 'master' sh 'cp "$MYSQL_CONFIG" db/remotes/$NODE_ENV.ini'
}} }
steps {
configFileProvider([ sh 'npx myt push $NODE_ENV --force --commit'
configFile(fileId: "config.${NODE_ENV}.ini", }
variable: 'MYSQL_CONFIG')
]) {
sh 'mkdir -p db/remotes'
sh 'cp "$MYSQL_CONFIG" db/remotes/$NODE_ENV.ini'
} }
nodejs('node-v20') { stage('Docker') {
sh 'npx myt push $NODE_ENV --force --commit' when {
expression { return FROM_GIT }
}
environment {
DOCKER_HOST = "${env.SWARM_HOST}"
}
steps {
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
}
} }
} }
} }
@ -122,7 +151,7 @@ pipeline {
post { post {
always { always {
script { script {
if (!['master', 'test'].contains(env.BRANCH_NAME)) { if (RUN_TESTS) {
try { try {
junit 'junitresults.xml' junit 'junitresults.xml'
junit 'junit.xml' junit 'junit.xml'
@ -130,18 +159,28 @@ pipeline {
echo e.toString() echo e.toString()
} }
} }
}
}
success {
script {
if (env.BRANCH_NAME == 'master' && FROM_GIT) {
String message = env.GIT_COMMIT_MSG
int index = message.indexOf('\n')
if (index != -1)
message = message.substring(0, index)
if (!env.COMMITTER_EMAIL || currentBuild.currentResult == 'SUCCESS') return; rocketSend(
try { channel: 'vn-database',
mail( message: "*DB version uploaded:* ${message}"
to: env.COMMITTER_EMAIL, +"\n$COMMITTER_EMAIL ($BRANCH_NAME)"
subject: "Pipeline: ${env.JOB_NAME} (${env.BUILD_NUMBER}): ${currentBuild.currentResult}", +"\n$GIT_URL/commit/$GIT_COMMIT",
body: "Check status at ${env.BUILD_URL}" rawMessage: true
) )
} catch (e) {
echo e.toString()
} }
} }
} }
unsuccessful {
sendEmail()
}
} }
} }

View File

@ -1,7 +1,7 @@
version: '3.7' version: '3.7'
services: services:
front: front:
image: registry.verdnatura.es/salix-front:${BRANCH_NAME:?} image: registry.verdnatura.es/salix-front:${VERSION:?}
build: build:
context: . context: .
dockerfile: front/Dockerfile dockerfile: front/Dockerfile
@ -16,7 +16,7 @@ services:
limits: limits:
memory: 1G memory: 1G
back: back:
image: registry.verdnatura.es/salix-back:${BRANCH_NAME:?} image: registry.verdnatura.es/salix-back:${VERSION:?}
build: . build: .
ports: ports:
- 3000 - 3000

View File

@ -1,6 +1,6 @@
{ {
"name": "salix-back", "name": "salix-back",
"version": "24.06.01", "version": "24.6.0",
"author": "Verdnatura Levante SL", "author": "Verdnatura Levante SL",
"description": "Salix backend", "description": "Salix backend",
"license": "GPL-3.0", "license": "GPL-3.0",