Files
TallerCiCd/Jenkinsfile.ci
2026-01-17 12:33:49 +01:00

101 lines
2.0 KiB
Plaintext

pipeline {
agent none
options {
timestamps()
}
environment {
NODE_OPTIONS = '--max_old_space_size=2048'
}
stages {
stage('Init') {
agent any
steps {
script {
env.COMMIT_AUTHOR = sh(
script: "git show -s --format=%an HEAD",
returnStdout: true
).trim()
env.COMMIT_SHORT = sh(
script: "git rev-parse --short HEAD",
returnStdout: true
).trim()
}
echo "CI build for commit ${env.COMMIT_SHORT} by ${env.COMMIT_AUTHOR}"
}
}
/* =========================
BACKEND CI
========================= */
stage('Backend: lint & test') {
agent {
docker {
image 'python:3.11-slim'
}
}
environment {
HOME = "${WORKSPACE}"
PIP_CACHE_DIR = "${WORKSPACE}/.cache/pip"
PYTHONDONTWRITEBYTECODE = 1
}
steps {
dir('backend') {
sh '''
set -e
mkdir -p "$PIP_CACHE_DIR" "$WORKSPACE/.cache/pytest"
python -m venv .venv
. .venv/bin/activate
pip install --upgrade pip
pip install -r requirements-dev.txt
ruff check app tests
pytest -o cache_dir="$WORKSPACE/.cache/pytest"
'''
}
}
}
/* =========================
FRONTEND CI
========================= */
stage('Frontend: check & build') {
agent {
docker {
image 'node:20-slim'
}
}
environment {
HOME = "${WORKSPACE}"
NPM_CONFIG_CACHE = "${WORKSPACE}/.cache/npm"
}
steps {
dir('frontend') {
sh '''
set -e
mkdir -p "$NPM_CONFIG_CACHE"
npm install --no-progress --no-audit --prefer-offline
npm run check
npm run build
'''
}
}
}
}
post {
always {
cleanWs()
}
}
}