50 lines
1.8 KiB
Plaintext
50 lines
1.8 KiB
Plaintext
pipeline {
|
|
agent any
|
|
stages {
|
|
stage('Build') {
|
|
steps {
|
|
script {
|
|
dir('project2') {
|
|
// Folosim --no-cache ca să fim siguri că ia noul Python
|
|
sh "docker build --no-cache -t quotes-app ."
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Run') {
|
|
steps {
|
|
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 ."
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
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')
|
|
}
|
|
|
|
sh """
|
|
cat << 'EOF' > discord_payload.json
|
|
{
|
|
"content": "✅ **Pipeline Finalizat (Build #${env.BUILD_NUMBER})**\\n\\n${quoteContent}"
|
|
}
|
|
EOF
|
|
"""
|
|
sh "curl -X POST -H 'Content-Type: application/json' --data-binary @discord_payload.json '${discordUrl}'"
|
|
}
|
|
}
|
|
}
|
|
} |