This commit is contained in:
Ionel Andrei Cataon
2026-02-12 16:24:27 +02:00
parent 7f61b029d4
commit 13c9543797

View File

@@ -13,7 +13,6 @@ pipeline {
script { script {
dir('project2') { dir('project2') {
echo "🔍 Verificăm sintaxa Python..." echo "🔍 Verificăm sintaxa Python..."
// Construim o imagine de test ca să fim siguri că avem toate dependințele
sh "docker build -t lint-test ." sh "docker build -t lint-test ."
sh "docker run --rm lint-test python -m py_compile famousquotes.py" sh "docker run --rm lint-test python -m py_compile famousquotes.py"
} }
@@ -27,8 +26,11 @@ pipeline {
dir('project2') { dir('project2') {
echo "🏗️ Construim și rulăm aplicația..." echo "🏗️ Construim și rulăm aplicația..."
sh "docker build -t quotes-app ." sh "docker build -t quotes-app ."
// Folosim API-ul care dă cheia 'content' pe HTTP ca să evităm eroarea SSL sau 'indices'
sh "docker run --rm -e QUOTE_API_URL='http://api.staging.quotable.io/random' quotes-app" /* Folosim --network host pentru a împrumuta conexiunea care a mers la Proiectul 1.
Am schimbat API-ul cu unul extrem de simplu (AdviceSlip) care nu dă erori de SSL.
*/
sh "docker run --rm --network host -e QUOTE_API_URL='https://api.adviceslip.com/advice' quotes-app"
} }
} }
} }
@@ -39,18 +41,18 @@ pipeline {
always { always {
script { script {
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa" def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa"
def status = currentBuild.result ?: 'SUCCESS'
def emoji = (status == 'SUCCESS') ? "✅" : "❌"
writeFile file: 'discord.json', text: """ def result = currentBuild.result ?: 'SUCCESS'
{ def emoji = (result == 'SUCCESS') ? "✅" : "❌"
"content": "$emoji **Build #${env.BUILD_NUMBER}** s-a finalizat cu status: **$status**"
} echo "🚀 Trimitere notificare către Discord (Status: ${result})..."
// Folosim metoda cea mai simplă de curl care a mers la Proiectul 1
sh """
curl -X POST -H 'Content-Type: application/json' \
-d '{"content": "${emoji} **Proiect 2**: Build #${env.BUILD_NUMBER} s-a finalizat cu status: ${result}"}' \
${discordUrl}
""" """
echo "🚀 Trimitere notificare către Discord..."
// Adăugăm -v pentru a vedea în consolă dacă rețeaua blochează Discord-ul
sh "curl -v -X POST -H 'Content-Type: application/json' -d @discord.json '${discordUrl}'"
} }
} }
} }