From 166d263b76d0a8b685dd9c88ba439083b2ce2243 Mon Sep 17 00:00:00 2001 From: Ionel Andrei Cataon Date: Thu, 12 Feb 2026 16:11:26 +0200 Subject: [PATCH] u1 --- project2/jenkinsfile | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/project2/jenkinsfile b/project2/jenkinsfile index ee95716..940cc21 100644 --- a/project2/jenkinsfile +++ b/project2/jenkinsfile @@ -12,10 +12,7 @@ pipeline { 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 build -t lint-test ." sh "docker run --rm lint-test python -m py_compile famousquotes.py" } } @@ -27,7 +24,8 @@ pipeline { script { dir('project2') { sh "docker build -t quotes-app ." - sh "docker run --rm -e QUOTE_API_URL='https://api.quotable.io/random' quotes-app" + // ADAUGĂM --dns 8.8.8.8 pentru a rezolva eroarea de conexiune API + sh "docker run --rm --dns 8.8.8.8 -e QUOTE_API_URL='https://api.quotable.io/random' quotes-app" } } } @@ -35,17 +33,26 @@ pipeline { } post { - always { - // Aceasta va rula mereu daca Pipeline-ul trece de faza de compilare - echo "Pipeline-ul s-a terminat." + success { + script { + def discordUrl = 'https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa' + def payload = """ + { + "content": "✅ **SUCCESS: Famous Quotes App**\\nBuild-ul #${env.BUILD_NUMBER} a trecut cu succes! Aplicația a rulat corect." + } + """ + sh "curl -X POST -H 'Content-Type: application/json' -d '${payload.trim()}' '${discordUrl}'" + } } 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}'" + def payload = """ + { + "content": "❌ **FAILED: Famous Quotes App**\\nBuild-ul #${env.BUILD_NUMBER} a eșuat. Verifică log-urile din Jenkins!" + } + """ + sh "curl -X POST -H 'Content-Type: application/json' -d '${payload.trim()}' '${discordUrl}'" } } }