pj2
This commit is contained in:
@@ -2,21 +2,12 @@ pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Initialize & Notify') {
|
||||
steps {
|
||||
script {
|
||||
// Notificăm imediat ce pornește build-ul
|
||||
sendDiscordNotification("🚀 **Proiect 2**: Build #${env.BUILD_NUMBER} a început pe ramura develop.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Lint & Build') {
|
||||
steps {
|
||||
script {
|
||||
dir('project2') {
|
||||
sh "docker build -t quotes-app ."
|
||||
// Linting folosind imaginea construită
|
||||
// Linting simplu
|
||||
sh "docker run --rm quotes-app python -m py_compile famousquotes.py"
|
||||
}
|
||||
}
|
||||
@@ -26,29 +17,27 @@ pipeline {
|
||||
stage('Run App') {
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
dir('project2') {
|
||||
// Folosim un API compatibil care returnează cheia 'content'
|
||||
// și --network host pentru a asigura ieșirea spre Discord ulterior
|
||||
sh "docker run --rm --network host -e QUOTE_API_URL='http://api.staging.quotable.io/random' quotes-app"
|
||||
}
|
||||
sendDiscordNotification("✅ **Proiect 2**: Build #${env.BUILD_NUMBER} finalizat cu succes!")
|
||||
} catch (Exception e) {
|
||||
sendDiscordNotification("❌ **Proiect 2**: Build #${env.BUILD_NUMBER} a eșuat la execuție.")
|
||||
error("Build failed: ${e.message}")
|
||||
dir('project2') {
|
||||
// Folosim --network host și un DNS public pentru a forța ieșirea la internet
|
||||
sh "docker run --rm --network host --dns 8.8.8.8 -e QUOTE_API_URL='https://api.quotable.io/random' quotes-app"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Funcție separată pentru a fi siguri că apelul curl este curat
|
||||
def sendDiscordNotification(String message) {
|
||||
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa"
|
||||
sh """
|
||||
curl -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"content": "${message}"}' \
|
||||
${discordUrl}
|
||||
"""
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjJjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJWK38mqa"
|
||||
def status = currentBuild.result ?: 'SUCCESS'
|
||||
|
||||
sh """
|
||||
curl -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"content": "🚀 Build #${env.BUILD_NUMBER} s-a terminat cu status: ${status}"}' \
|
||||
'${discordUrl}'
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user