pipeline { agent any stages { stage('Checkout') { steps { checkout scm } } stage('Lint Check') { steps { script { dir('project2') { echo "Verificăm sintaxa Python prin construirea unui mic test..." // Construim o imagine rapida doar pentru a rula lint-ul sh "docker build -t lint-test -f Dockerfile ." // Rulam lint-ul INTERN in imaginea deja construita sh "docker run --rm lint-test python -m py_compile famousquotes.py" } } } } stage('Build & Run') { steps { script { dir('project2') { sh "docker build -t quotes-app ." sh "docker run --rm -e QUOTE_API_URL='https://api.quotable.io/random' quotes-app" } } } } } post { always { // Aceasta va rula mereu daca Pipeline-ul trece de faza de compilare echo "Pipeline-ul s-a terminat." } failure { script { // IMPORTANT: Pune URL-ul intre ghilimele simple pentru a evita interpretarea caracterelor speciale de catre shell def discordUrl = 'https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa' def payload = '{"content": "❌ **FAILED: Famous Quotes App**\\nBuild-ul #' + env.BUILD_NUMBER + ' a esuat!"}' sh "curl -H 'Content-Type: application/json' -d '${payload}' '${discordUrl}'" } } } }