Files
it_school/project2/jenkinsfile
Ionel Andrei Cataon 13c9543797 pj2
2026-02-12 16:24:27 +02:00

59 lines
2.1 KiB
Plaintext

pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Lint Check') {
steps {
script {
dir('project2') {
echo "🔍 Verificăm sintaxa Python..."
sh "docker build -t lint-test ."
sh "docker run --rm lint-test python -m py_compile famousquotes.py"
}
}
}
}
stage('Build & Run') {
steps {
script {
dir('project2') {
echo "🏗️ Construim și rulăm aplicația..."
sh "docker build -t 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"
}
}
}
}
}
post {
always {
script {
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa"
def result = currentBuild.result ?: 'SUCCESS'
def emoji = (result == 'SUCCESS') ? "✅" : "❌"
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}
"""
}
}
}
}