p2
This commit is contained in:
@@ -2,10 +2,17 @@ pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Lint & Build') {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Image') {
|
||||
steps {
|
||||
script {
|
||||
dir('project2') {
|
||||
// Construim imaginea aplicației
|
||||
sh "docker build -t quotes-app ."
|
||||
}
|
||||
}
|
||||
@@ -16,7 +23,10 @@ pipeline {
|
||||
steps {
|
||||
script {
|
||||
dir('project2') {
|
||||
// Folosim -v $(pwd):/app pentru ca Python să poată scrie quote.txt în folderul proiectului
|
||||
echo "🚀 Rulăm aplicația și salvăm citatul..."
|
||||
/* -v \$(pwd):/app -> mapează folderul curent din Jenkins în /app din container.
|
||||
Astfel, quote.txt creat de Python va apărea direct în folderul project2.
|
||||
*/
|
||||
sh "docker run --rm --network host -v \$(pwd):/app -e QUOTE_API_URL='https://api.quotable.io/random' quotes-app"
|
||||
}
|
||||
}
|
||||
@@ -27,22 +37,26 @@ pipeline {
|
||||
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"
|
||||
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjJjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJWK38mqa"
|
||||
|
||||
// Trimitem mesajul formatat
|
||||
def quoteContent = readFile('project2/quote.txt').trim()
|
||||
|
||||
echo "Trimitem citatul pe Discord..."
|
||||
sh """
|
||||
curl -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"content": "✅ **Citatul Zilei (Build #${env.BUILD_NUMBER})**\\n\\n${messageContent}"}' \
|
||||
-d '{"content": "✅ **Build #${env.BUILD_NUMBER} Finalizat cu Succes!**\\n\\n${quoteContent}"}' \
|
||||
'${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}'"
|
||||
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjJjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJWK38mqa"
|
||||
sh """
|
||||
curl -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"content": "❌ **Build #${env.BUILD_NUMBER} a eșuat!** Verifică log-urile din Jenkins."}' \
|
||||
'${discordUrl}'
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user