This commit is contained in:
Ionel Andrei Cataon
2026-02-12 16:50:19 +02:00
parent f6b3f8ad85
commit b58666ead4
2 changed files with 66 additions and 67 deletions

View File

@@ -1,30 +1,56 @@
pipeline {
agent any
stages {
stage('Build & Run') {
stage('Build & Lint') {
steps {
script {
dir('project2') {
// 1. Construim imaginea
sh "docker build -t quotes-app ."
// 2. LINT CHECK: Verificăm sintaxa Python în interiorul containerului
echo "🔍 Verificăm sintaxa codului..."
sh "docker run --rm quotes-app python -m py_compile famousquotes.py"
}
}
}
}
stage('Run & Extract') {
steps {
script {
dir('project2') {
try {
// Adăugăm --dns 8.8.8.8 pentru a rezolva problema de rețea
sh "docker run --name quotes-container --network host --dns 8.8.8.8 quotes-app"
sh "docker cp quotes-container:/app/quote.txt ."
// 3. Rulăm cu DNS forțat pentru a evita "NameResolutionError"
sh "docker run --name quotes-worker --network host --dns 8.8.8.8 quotes-app"
// 4. Extragem rezultatul
sh "docker cp quotes-worker:/app/quote.txt ."
} catch (e) {
echo "Eroare la execuție."
echo "Eroare la rulare, dar încercăm notificarea."
} finally {
sh "docker rm -f quotes-container || true"
sh "docker rm -f quotes-worker || true"
}
}
}
}
}
}
post {
always {
script {
// !!! Pune Webhook-ul tău aici !!!
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjJjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJWK38mqa"
def quoteText = readFile('project2/quote.txt').trim()
def quoteText = "Nu am putut citi fișierul."
try {
quoteText = readFile('project2/quote.txt').trim()
} catch (err) {
echo "Fișierul nu a fost găsit."
}
def statusEmoji = (currentBuild.result == 'SUCCESS') ? "✅" : "⚠️"
sh """