57 lines
2.0 KiB
Plaintext
57 lines
2.0 KiB
Plaintext
pipeline {
|
|
agent any
|
|
|
|
stages {
|
|
stage('Checkout') {
|
|
steps {
|
|
checkout scm
|
|
}
|
|
}
|
|
|
|
stage('Lint Check') {
|
|
steps {
|
|
script {
|
|
dir('project2') {
|
|
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 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 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"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
always {
|
|
script {
|
|
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa"
|
|
def status = currentBuild.result ?: 'SUCCESS'
|
|
def emoji = (status == 'SUCCESS') ? "✅" : "❌"
|
|
|
|
writeFile file: 'discord.json', text: """
|
|
{
|
|
"content": "$emoji **Build #${env.BUILD_NUMBER}** s-a finalizat cu status: **$status**"
|
|
}
|
|
"""
|
|
|
|
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}'"
|
|
}
|
|
}
|
|
}
|
|
} |