38 lines
1.5 KiB
Plaintext
38 lines
1.5 KiB
Plaintext
pipeline {
|
|
agent any
|
|
stages {
|
|
stage('Build & Run') {
|
|
steps {
|
|
script {
|
|
dir('project2') {
|
|
sh "docker build -t quotes-app ."
|
|
try {
|
|
// Adăugăm --dns 8.8.8.8 pentru a rezolva problema de rețea
|
|
sh "docker run --name quotes-container --network host --dns 8.8.8.8 quotes-app"
|
|
sh "docker cp quotes-container:/app/quote.txt ."
|
|
} catch (e) {
|
|
echo "Eroare la execuție."
|
|
} finally {
|
|
sh "docker rm -f quotes-container || true"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
script {
|
|
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjJjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJWK38mqa"
|
|
def quoteText = readFile('project2/quote.txt').trim()
|
|
def statusEmoji = (currentBuild.result == 'SUCCESS') ? "✅" : "⚠️"
|
|
|
|
sh """
|
|
curl -X POST -H 'Content-Type: application/json' \
|
|
-d '{"content": "${statusEmoji} **Pipeline Finalizat (Build #${env.BUILD_NUMBER})**\\n\\n${quoteText}"}' \
|
|
'${discordUrl}'
|
|
"""
|
|
}
|
|
}
|
|
}
|
|
} |