From 76ee23a8562ab9b1080d59a58065d959c274e17a Mon Sep 17 00:00:00 2001 From: Ionel Andrei Cataon Date: Thu, 12 Feb 2026 16:09:30 +0200 Subject: [PATCH] u3 --- project2/jenkinsfile | 53 ++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/project2/jenkinsfile b/project2/jenkinsfile index a6506da..ee95716 100644 --- a/project2/jenkinsfile +++ b/project2/jenkinsfile @@ -7,57 +7,46 @@ pipeline { checkout scm } } - - stage('Debug Path') { - steps { - sh 'echo "Suntem in folderul:" && pwd' - sh 'echo "Continutul folderului este:" && ls -R' - } - } stage('Lint Check') { steps { script { - echo "Verificăm sintaxa Python..." - // Am adaugat -v pentru ca Docker sa vada fisierele din Jenkins - sh 'docker run --rm -v "${WORKSPACE}/project2":/app -w /app python:3.9-slim python -m py_compile famousquotes.py' + 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 Docker Image') { + stage('Build & Run') { steps { script { - // Ne mutam in folderul proiectului pentru build - sh 'cd project2 && docker build -t quotes-app .' - } - } - } - - stage('Run & Test API') { - steps { - script { - echo "Rulăm aplicația..." - sh 'docker run --rm -e QUOTE_API_URL="https://api.quotable.io/random" quotes-app' + 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 { - def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa" - def payload = """ - { - "content": "❌ **FAILED: Famous Quotes App**\\nEtapa a eșuat la build-ul #${env.BUILD_NUMBER}. Verifica codul Python!" - } - """ + // 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}'" } } - success { - echo "Proiectul 2 a fost build-uit cu succes!" - } } -} \ No newline at end of file +} \ No newline at end of file