pipeline { agent any stages { stage('Checkout') { steps { // Descarcă codul din repository checkout scm } } stage('Lint Check') { steps { script { dir('project2') { echo "Verificăm sintaxa Python..." // Construim o imagine de test pentru a rula verificarea în interiorul ei sh "docker build -t lint-test ." sh "docker run --rm lint-test python -m py_compile famousquotes.py" } } } } stage('Build Docker Image') { steps { script { dir('project2') { echo "Construim imaginea finală..." sh "docker build -t quotes-app ." } } } } stage('Run & Test API') { steps { script { dir('project2') { echo "Rulăm aplicația..." // Folosim un API care returnează obiect (nu listă) pentru a evita eroarea 'indices must be integers' sh "docker run --rm -e QUOTE_API_URL='https://api.adviceslip.com/advice' quotes-app" } } } } } post { always { script { def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa" // Stabilim statusul pentru mesaj def status = currentBuild.result == 'SUCCESS' ? "✅ SUCCESS" : "❌ FAILED" // Scriem payload-ul într-un fișier pentru a evita problemele cu ghilimelele în shell writeFile file: 'discord_payload.json', text: """ { "content": "$status: Build #${env.BUILD_NUMBER} s-a finalizat pe branch-ul develop." } """ echo "Trimitere notificare Discord..." // Trimitem fișierul JSON direct cu curl sh "curl -X POST -H 'Content-Type: application/json' -d @discord_payload.json '${discordUrl}'" } } } }