up1
This commit is contained in:
@@ -3,13 +3,18 @@ pipeline {
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps { checkout scm }
|
||||
steps {
|
||||
// Descarcă codul din repository
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
|
||||
stage('Lint Check') {
|
||||
steps {
|
||||
script {
|
||||
dir('project2') {
|
||||
echo "Verificăm sintaxa Python..."
|
||||
// Construim o imagine de test pentru a rula verificarea în interiorul ei
|
||||
sh "docker build -t lint-test ."
|
||||
sh "docker run --rm lint-test python -m py_compile famousquotes.py"
|
||||
}
|
||||
@@ -17,12 +22,24 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build & Run') {
|
||||
stage('Build Docker Image') {
|
||||
steps {
|
||||
script {
|
||||
dir('project2') {
|
||||
echo "Construim imaginea finală..."
|
||||
sh "docker build -t quotes-app ."
|
||||
sh "docker run --rm -e QUOTE_API_URL='https://zenquotes.io/api/random' quotes-app"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Run & Test API') {
|
||||
steps {
|
||||
script {
|
||||
dir('project2') {
|
||||
echo "Rulăm aplicația..."
|
||||
// Folosim un API care returnează obiect (nu listă) pentru a evita eroarea 'indices must be integers'
|
||||
sh "docker run --rm -e QUOTE_API_URL='https://api.adviceslip.com/advice' quotes-app"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,18 +51,19 @@ pipeline {
|
||||
script {
|
||||
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa"
|
||||
|
||||
def statusEmoji = currentBuild.result == 'SUCCESS' ? "✅" : "❌"
|
||||
def statusText = currentBuild.result == 'SUCCESS' ? "SUCCESS" : "FAILED"
|
||||
// Stabilim statusul pentru mesaj
|
||||
def status = currentBuild.result == 'SUCCESS' ? "✅ SUCCESS" : "❌ FAILED"
|
||||
|
||||
// Cream un fisier JSON curat pentru a evita erorile de ghilimele
|
||||
writeFile file: 'discord.json', text: """
|
||||
// Scriem payload-ul într-un fișier pentru a evita problemele cu ghilimelele în shell
|
||||
writeFile file: 'discord_payload.json', text: """
|
||||
{
|
||||
"content": "$statusEmoji **$statusText**: Build #${env.BUILD_NUMBER} s-a terminat pe ramura develop."
|
||||
"content": "$status: Build #${env.BUILD_NUMBER} s-a finalizat pe branch-ul develop."
|
||||
}
|
||||
"""
|
||||
|
||||
echo "Trimitere notificare catre Discord..."
|
||||
sh "curl -X POST -H 'Content-Type: application/json' -d @discord.json '$discordUrl'"
|
||||
echo "Trimitere notificare Discord..."
|
||||
// Trimitem fișierul JSON direct cu curl
|
||||
sh "curl -X POST -H 'Content-Type: application/json' -d @discord_payload.json '${discordUrl}'"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user