jenkinsfile
This commit is contained in:
parent
3c334093de
commit
31d7e8d3da
48
Jenkinsfile.groovy → Jenkinsfile
vendored
48
Jenkinsfile.groovy → Jenkinsfile
vendored
@ -1,29 +1,25 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Build backend') {
|
||||
agent {
|
||||
docker {
|
||||
image 'rust:buster'
|
||||
// args '-v /srv/jenkins/.cargo:/root/.cargo'
|
||||
// reuseNode true
|
||||
environment {
|
||||
PATH = "/var/lib/jenkins/.cargo/bin:${env.PATH}"
|
||||
}
|
||||
}
|
||||
|
||||
steps {
|
||||
sh "sh cargo install"
|
||||
sh "sh cargo --version"
|
||||
sh "cd ${env.WORKSPACE}/backend"
|
||||
sh "touch .env"
|
||||
sh "echo DATABASE_URL=mysql://educa7ls_user:123456789a*@md-89.webhostbox.net:3306/educa7ls_plataforma >> .env"
|
||||
sh "echo RENIEC_API=apis-token-1.aTSI1U7KEuT-6bbbCguH-4Y8TI6KS73N >> .env"
|
||||
sh "cargo build --release"
|
||||
}
|
||||
}
|
||||
stage('Build frontend') {
|
||||
agent {
|
||||
docker { image 'node:18.18.0-alpine3.18' }
|
||||
environment {
|
||||
PATH = "/var/lib/jenkins/.nvm/versions/node/v18.18.0/bin:${env.PATH}"
|
||||
}
|
||||
steps {
|
||||
sh "cd ${env.WORKSPACE}/frontend"
|
||||
sh "echo VITE_BACKEND_URL=https://system.eegsac.com >> .env.production"
|
||||
sh "pnpm i"
|
||||
sh "pnpm build"
|
||||
}
|
||||
@ -34,9 +30,16 @@ pipeline {
|
||||
sh "touch .env"
|
||||
sh "echo DATABASE_URL=mysql://educa7ls_user:123456789a*@md-89.webhostbox.net:3306/educa7ls_plataforma >> .env"
|
||||
sh "echo RENIEC_API=apis-token-1.aTSI1U7KEuT-6bbbCguH-4Y8TI6KS73N >> .env"
|
||||
sh "echo CLASSROOM_URL=https://aulavirtual.eegsac.com >> .env"
|
||||
sh "echo CLASSROOM_USER=admin >> .env"
|
||||
sh "echo CLASSROOM_PASSWORD=YVL1@N4_PaL0-93\\$ >> .env"
|
||||
sh "echo RUST_LOG=info >> .env"
|
||||
}
|
||||
}
|
||||
stage("Stop old PM2 processes") {
|
||||
environment {
|
||||
PATH = "/var/lib/jenkins/.local/share/pnpm:${env.PATH}"
|
||||
}
|
||||
steps {
|
||||
sh "pm2 stop ${env.JOB_BASE_NAME} || true"
|
||||
sh "pm2 delete ${env.JOB_BASE_NAME} || true"
|
||||
@ -49,20 +52,25 @@ pipeline {
|
||||
}
|
||||
stage("Copy deploy files") {
|
||||
steps {
|
||||
sh "mkdir -p /var/deploys/${env.JOB_BASE_NAME}/${env.BUILD_TAG}/static"
|
||||
sh "mkdir -p /var/deploys/${env.JOB_BASE_NAME}/static"
|
||||
// Copy backend binary
|
||||
sh "cp ${env.WORKSPACE}/backend/target/release/backend /var/deploys/${env.JOB_BASE_NAME}/${env.BUILD_TAG}/"
|
||||
sh "cp ${env.WORKSPACE}/backend/target/release/backend /var/deploys/${env.JOB_BASE_NAME}/"
|
||||
// Copy frontend static files
|
||||
sh "cp -r ${env.WORKSPACE}/frontend/dist/* /var/deploys/${env.JOB_BASE_NAME}/${env.BUILD_TAG}/static/"
|
||||
// Copy ENV file
|
||||
sh "cp ${env.WORKSPACE}/.env /var/deploys/${env.JOB_BASE_NAME}/${env.BUILD_TAG}/"
|
||||
sh "cp -r ${env.WORKSPACE}/frontend/dist/* /var/deploys/${env.JOB_BASE_NAME}/static/"
|
||||
// Copy ENV file for RUST
|
||||
sh "cp ${env.WORKSPACE}/.env /var/deploys/${env.JOB_BASE_NAME}/"
|
||||
// Make log dir
|
||||
sh "mkdir -p /var/deploys/${env.JOB_BASE_NAME}/request-logs/"
|
||||
}
|
||||
}
|
||||
stage('Start app with PM2') {
|
||||
environment {
|
||||
PATH = "/var/lib/jenkins/.local/share/pnpm:${env.PATH}"
|
||||
}
|
||||
steps {
|
||||
sh "cd /var/deploys/${env.JOB_BASE_NAME}/${env.BUILD_TAG}/"
|
||||
// ROCKET_PORT=3333
|
||||
sh "pm2 start backend --name ${env.JOB_BASE_NAME}"
|
||||
sh "cd /var/deploys/${env.JOB_BASE_NAME}/"
|
||||
sh "ROCKET_PORT=3333 pm2 start backend --name ${env.JOB_BASE_NAME}"
|
||||
sh "pm2 save"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user