Files
it_school/project2/jenkinsfile
Ionel Andrei Cataon f507bf03b8 up3
2026-02-12 16:18:27 +02:00

52 lines
1.7 KiB
Plaintext

pipeline {
agent any
stages {
stage('Checkout') {
steps { checkout scm }
}
stage('Lint Check') {
steps {
script {
dir('project2') {
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') {
sh "docker build -t quotes-app ."
sh "docker run --rm -e QUOTE_API_URL='https://zenquotes.io/api/random' quotes-app"
}
}
}
}
}
post {
always {
script {
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa"
def statusEmoji = currentBuild.result == 'SUCCESS' ? "✅" : "❌"
def statusText = currentBuild.result == 'SUCCESS' ? "SUCCESS" : "FAILED"
// Cream un fisier JSON curat pentru a evita erorile de ghilimele
writeFile file: 'discord.json', text: """
{
"content": "$statusEmoji **$statusText**: Build #${env.BUILD_NUMBER} s-a terminat pe ramura develop."
}
"""
echo "Trimitere notificare catre Discord..."
sh "curl -X POST -H 'Content-Type: application/json' -d @discord.json '$discordUrl'"
}
}
}
}