From 8b8046167716c4f027f745ee5d1a42a6a3da11b0 Mon Sep 17 00:00:00 2001 From: Ionel Andrei Cataon Date: Thu, 12 Feb 2026 16:20:23 +0200 Subject: [PATCH] up1 --- project2/jenkinsfile | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/project2/jenkinsfile b/project2/jenkinsfile index 2898710..d5bc2f5 100644 --- a/project2/jenkinsfile +++ b/project2/jenkinsfile @@ -3,13 +3,18 @@ pipeline { stages { stage('Checkout') { - steps { checkout scm } + 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" } @@ -17,12 +22,24 @@ pipeline { } } - stage('Build & Run') { + stage('Build Docker Image') { steps { script { dir('project2') { + echo "Construim imaginea finală..." sh "docker build -t quotes-app ." - sh "docker run --rm -e QUOTE_API_URL='https://zenquotes.io/api/random' 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" } } } @@ -34,18 +51,19 @@ pipeline { script { def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa" - def statusEmoji = currentBuild.result == 'SUCCESS' ? "✅" : "❌" - def statusText = currentBuild.result == 'SUCCESS' ? "SUCCESS" : "FAILED" + // Stabilim statusul pentru mesaj + def status = currentBuild.result == 'SUCCESS' ? "✅ SUCCESS" : "❌ FAILED" - // Cream un fisier JSON curat pentru a evita erorile de ghilimele - writeFile file: 'discord.json', text: """ + // Scriem payload-ul într-un fișier pentru a evita problemele cu ghilimelele în shell + writeFile file: 'discord_payload.json', text: """ { - "content": "$statusEmoji **$statusText**: Build #${env.BUILD_NUMBER} s-a terminat pe ramura develop." + "content": "$status: Build #${env.BUILD_NUMBER} s-a finalizat pe branch-ul develop." } """ - echo "Trimitere notificare catre Discord..." - sh "curl -X POST -H 'Content-Type: application/json' -d @discord.json '$discordUrl'" + 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}'" } } }