diff --git a/project2/jenkinsfile b/project2/jenkinsfile index 755dd5e..5fae9b6 100644 --- a/project2/jenkinsfile +++ b/project2/jenkinsfile @@ -22,8 +22,8 @@ pipeline { script { dir('project2') { sh "docker build -t quotes-app ." - // Mapăm manual IP-ul pentru a sări peste problema de DNS - sh "docker run --rm --add-host api.quotable.io:104.21.23.210 -e QUOTE_API_URL='https://api.quotable.io/random' quotes-app" + // Folosim HTTP pentru a evita handshake-ul SSL problematic si adaugam host-ul manual + sh "docker run --rm --add-host api.quotable.io:104.21.23.210 -e QUOTE_API_URL='http://api.quotable.io/random' quotes-app" } } } @@ -31,18 +31,18 @@ pipeline { } post { - success { + always { script { - def msg = "✅ **SUCCESS**: Build #${env.BUILD_NUMBER} a trecut cu succes!" - sh "echo '{\"content\": \"$msg\"}' > discord_success.json" - sh "curl -X POST -H 'Content-Type: application/json' -d @discord_success.json 'https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa'" - } - } - failure { - script { - def msg = "❌ **FAILED**: Build #${env.BUILD_NUMBER} a eșuat. Verifică DNS-ul sau codul!" - sh "echo '{\"content\": \"$msg\"}' > discord_fail.json" - sh "curl -X POST -H 'Content-Type: application/json' -d @discord_fail.json 'https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa'" + // Mapam manual IP-ul Discord (162.159.135.232) pentru a asigura trimiterea + def discordIP = "162.159.135.232" + def webhookUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa" + + // Determinam mesajul in functie de statusul build-ului + def status = currentBuild.result == 'SUCCESS' ? "✅ SUCCESS" : "❌ FAILED" + def payload = "{\"content\": \"**$status**: Build #${env.BUILD_NUMBER} pe branch-ul develop.\"}" + + echo "Trimitere notificare Discord..." + sh "curl -X POST -H 'Content-Type: application/json' --resolve discord.com:443:$discordIP -d '$payload' '$webhookUrl'" } } }