p2
This commit is contained in:
@@ -37,30 +37,25 @@ pipeline {
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa"
|
||||
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjJjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJWK38mqa"
|
||||
|
||||
def quoteText = "Nu am putut citi fișierul."
|
||||
try {
|
||||
// Verificăm dacă fișierul există înainte de citire
|
||||
if (fileExists('project2/quote.txt')) {
|
||||
quoteText = readFile('project2/quote.txt').trim()
|
||||
// Curățăm ghilimelele care pot strica JSON-ul curl-ului
|
||||
quoteText = quoteText.replace('"', "'")
|
||||
}
|
||||
} catch (err) {
|
||||
echo "Fișierul nu a fost găsit: ${err}"
|
||||
if (fileExists('project2/quote.txt')) {
|
||||
quoteText = readFile('project2/quote.txt').trim()
|
||||
// Scoatem ghilimelele duble din citat ca să nu strice JSON-ul
|
||||
quoteText = quoteText.replace('"', "'")
|
||||
}
|
||||
|
||||
// Determinăm statusul final (dacă e null, punem succes implicit)
|
||||
def resultStatus = currentBuild.result ?: 'SUCCESS'
|
||||
def statusEmoji = (resultStatus == 'SUCCESS') ? "✅" : "⚠️"
|
||||
|
||||
echo "🚀 Trimitere notificare către Discord..."
|
||||
sh """
|
||||
curl -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"content": "${statusEmoji} **Pipeline Finalizat (Build #${env.BUILD_NUMBER})**\\n\\n${quoteText}"}' \
|
||||
'${discordUrl}'
|
||||
"""
|
||||
|
||||
// REPARARE: Definim payload-ul separat pentru claritate
|
||||
def payload = """{"content": "${statusEmoji} **Pipeline Finalizat (Build #${env.BUILD_NUMBER})**\\n\\n${quoteText}"}"""
|
||||
|
||||
// Folosim ghilimele simple pentru URL în comanda shell
|
||||
sh "curl -X POST -H 'Content-Type: application/json' -d '${payload}' '${discordUrl}'"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user