up1
This commit is contained in:
@@ -3,13 +3,18 @@ pipeline {
|
|||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Checkout') {
|
stage('Checkout') {
|
||||||
steps { checkout scm }
|
steps {
|
||||||
|
// Descarcă codul din repository
|
||||||
|
checkout scm
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Lint Check') {
|
stage('Lint Check') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
dir('project2') {
|
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 build -t lint-test ."
|
||||||
sh "docker run --rm lint-test python -m py_compile famousquotes.py"
|
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 {
|
steps {
|
||||||
script {
|
script {
|
||||||
dir('project2') {
|
dir('project2') {
|
||||||
|
echo "Construim imaginea finală..."
|
||||||
sh "docker build -t quotes-app ."
|
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 {
|
script {
|
||||||
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa"
|
def discordUrl = "https://discord.com/api/webhooks/1471492658336891013/T5s6ZKZjjDMHXc3k3jjZdk6m5EV12bKF1wda9d5I_gZJrsDZQ1m1m078IiLJwk38mqa"
|
||||||
|
|
||||||
def statusEmoji = currentBuild.result == 'SUCCESS' ? "✅" : "❌"
|
// Stabilim statusul pentru mesaj
|
||||||
def statusText = currentBuild.result == 'SUCCESS' ? "SUCCESS" : "FAILED"
|
def status = currentBuild.result == 'SUCCESS' ? "✅ SUCCESS" : "❌ FAILED"
|
||||||
|
|
||||||
// Cream un fisier JSON curat pentru a evita erorile de ghilimele
|
// Scriem payload-ul într-un fișier pentru a evita problemele cu ghilimelele în shell
|
||||||
writeFile file: 'discord.json', text: """
|
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..."
|
echo "Trimitere notificare Discord..."
|
||||||
sh "curl -X POST -H 'Content-Type: application/json' -d @discord.json '$discordUrl'"
|
// 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