p2
This commit is contained in:
@@ -5,7 +5,6 @@ pipeline {
|
||||
steps {
|
||||
script {
|
||||
dir('project2') {
|
||||
// Folosim --no-cache ca să fim siguri că ia noul Python
|
||||
sh "docker build --no-cache -t quotes-app ."
|
||||
}
|
||||
}
|
||||
@@ -16,11 +15,8 @@ pipeline {
|
||||
script {
|
||||
dir('project2') {
|
||||
sh "docker rm -f quotes-worker || true"
|
||||
// Testăm rețeaua înainte de rulare
|
||||
sh "docker run --rm --dns 8.8.8.8 alpine ping -c 2 google.com || echo 'Internet indisponibil'"
|
||||
|
||||
sh "docker run --name quotes-worker --dns 8.8.8.8 quotes-app"
|
||||
sh "docker cp quotes-worker:/app/quote.txt ."
|
||||
sh "docker cp quotes-worker:/app/quote.txt . "
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,20 +26,19 @@ pipeline {
|
||||
always {
|
||||
script {
|
||||
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjJjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJWK38mqa"
|
||||
def quoteContent = "Eroare la citirea fișierului."
|
||||
if (fileExists('project2/quote.txt')) {
|
||||
quoteContent = readFile('project2/quote.txt').trim()
|
||||
quoteContent = quoteContent.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n')
|
||||
}
|
||||
def quote = fileExists('project2/quote.txt') ? readFile('project2/quote.txt').trim() : "Nu am putut genera citatul."
|
||||
|
||||
// Escapăm citatul pentru JSON
|
||||
def safeQuote = quote.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n')
|
||||
|
||||
sh """
|
||||
cat << 'EOF' > discord_payload.json
|
||||
cat << 'EOF' > payload.json
|
||||
{
|
||||
"content": "✅ **Pipeline Finalizat (Build #${env.BUILD_NUMBER})**\\n\\n${quoteContent}"
|
||||
"content": "✅ **Pipeline Finalizat (Build #${env.BUILD_NUMBER})**\\n\\n${safeQuote}"
|
||||
}
|
||||
EOF
|
||||
"""
|
||||
sh "curl -X POST -H 'Content-Type: application/json' --data-binary @discord_payload.json '${discordUrl}'"
|
||||
sh "curl -X POST -H 'Content-Type: application/json' --data-binary @payload.json '${discordUrl}'"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user