eeg_certs/Jenkinsfile

80 lines
3.1 KiB
Plaintext
Raw Normal View History

2023-08-30 23:28:11 +00:00
pipeline {
agent any
stages {
stage('Build backend') {
2023-11-04 15:05:47 +00:00
environment {
PATH = "/var/lib/jenkins/.cargo/bin:${env.PATH}"
2023-09-26 22:22:20 +00:00
}
2023-08-30 23:28:11 +00:00
steps {
2023-11-04 15:12:55 +00:00
dir("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"
}
2023-08-30 23:28:11 +00:00
}
}
stage('Build frontend') {
2023-11-04 15:05:47 +00:00
environment {
PATH = "/var/lib/jenkins/.nvm/versions/node/v18.18.0/bin:${env.PATH}"
2023-09-26 22:22:20 +00:00
}
2023-08-30 23:28:11 +00:00
steps {
2023-11-04 15:12:55 +00:00
dir("frontend") {
sh "echo VITE_BACKEND_URL=https://system.eegsac.com >> .env.production"
sh "pnpm i"
sh "pnpm build"
}
2023-08-30 23:28:11 +00:00
}
}
stage("Create ENV file") {
steps {
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"
2023-11-04 15:05:47 +00:00
sh "echo CLASSROOM_URL=https://aulavirtual.eegsac.com >> .env"
sh "echo CLASSROOM_USER=admin >> .env"
2023-11-04 15:09:51 +00:00
sh '''echo CLASSROOM_PASSWORD=YVL1@N4_PaL0-93\\$ >> .env'''
2023-11-04 15:05:47 +00:00
sh "echo RUST_LOG=info >> .env"
2023-08-30 23:28:11 +00:00
}
}
stage("Stop old PM2 processes") {
2023-11-04 15:05:47 +00:00
environment {
PATH = "/var/lib/jenkins/.local/share/pnpm:${env.PATH}"
}
2023-08-30 23:28:11 +00:00
steps {
sh "pm2 stop ${env.JOB_BASE_NAME} || true"
sh "pm2 delete ${env.JOB_BASE_NAME} || true"
}
}
stage("Clean deploy folder") {
steps {
sh "rm -rf /var/deploys/${env.JOB_BASE_NAME}/* || true"
}
}
stage("Copy deploy files") {
steps {
2023-11-04 15:05:47 +00:00
sh "mkdir -p /var/deploys/${env.JOB_BASE_NAME}/static"
2023-08-30 23:28:11 +00:00
// Copy backend binary
2023-11-04 15:05:47 +00:00
sh "cp ${env.WORKSPACE}/backend/target/release/backend /var/deploys/${env.JOB_BASE_NAME}/"
2023-08-30 23:28:11 +00:00
// Copy frontend static files
2023-11-04 15:05:47 +00:00
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/"
2023-08-30 23:28:11 +00:00
}
}
stage('Start app with PM2') {
2023-11-04 15:05:47 +00:00
environment {
2023-11-04 15:26:30 +00:00
PATH = "/var/lib/jenkins/.local/share/pnpm:/var/lib/jenkins/.nvm/versions/node/v18.18.0/bin:${env.PATH}"
2023-11-04 15:05:47 +00:00
}
2023-08-30 23:28:11 +00:00
steps {
2023-11-04 15:17:37 +00:00
dir("/var/deploys/${env.JOB_BASE_NAME}/") {
sh "ROCKET_PORT=3333 pm2 start backend --name ${env.JOB_BASE_NAME}"
sh "pm2 save"
}
2023-08-30 23:28:11 +00:00
}
}
}
}