Files
it_school/project2/jenkinsfile
Ionel Andrei Cataon 04f2f26561 pj2
2026-02-12 16:36:00 +02:00

49 lines
1.6 KiB
Plaintext

pipeline {
agent any
stages {
stage('Lint & Build') {
steps {
script {
dir('project2') {
sh "docker build -t quotes-app ."
}
}
}
}
stage('Run & Save Quote') {
steps {
script {
dir('project2') {
// Folosim -v $(pwd):/app pentru ca Python să poată scrie quote.txt în folderul proiectului
sh "docker run --rm --network host -v \$(pwd):/app -e QUOTE_API_URL='https://api.quotable.io/random' quotes-app"
}
}
}
}
}
post {
success {
script {
// Citim fișierul generat de Python din folderul project2
def messageContent = readFile('project2/quote.txt').trim()
def discordUrl = "URL_UL_TAU_DE_DISCORD"
// Trimitem mesajul formatat
sh """
curl -X POST -H 'Content-Type: application/json' \
-d '{"content": "✅ **Citatul Zilei (Build #${env.BUILD_NUMBER})**\\n\\n${messageContent}"}' \
'${discordUrl}'
"""
}
}
failure {
script {
def discordUrl = "URL_UL_TAU_DE_DISCORD"
sh "curl -X POST -H 'Content-Type: application/json' -d '{\"content\": \"❌ **Build #${env.BUILD_NUMBER}** a eșuat. Verifică log-urile din Jenkins!\"}' '${discordUrl}'"
}
}
}
}