refactor: Update descriptions and messages in Jenkins pipeline scripts for clarity

This commit is contained in:
Thibault Pouch
2026-03-19 21:03:36 +01:00
parent 741e4043fa
commit 8f5b5d5e8d
2 changed files with 31 additions and 31 deletions

View File

@@ -5,22 +5,22 @@ pipeline {
string(
name: 'REPO_URL',
defaultValue: 'https://git.crowmate.fr/crowmate/Nest.git',
description: 'URL du repo Gitea (pour récupérer le docker-compose.prod.yml)'
description: 'Gitea repository URL (to retrieve docker-compose.prod.yml)'
)
string(
name: 'BRANCH',
defaultValue: 'main',
description: 'Branche'
description: 'Branch'
)
string(
name: 'STACK_NAME',
defaultValue: 'nest',
description: 'Nom de la stack dans Portainer'
description: 'Stack name in Portainer'
)
string(
name: 'IMAGE_TAG',
defaultValue: 'latest',
description: 'Tag des images à déployer'
description: 'Image tag to deploy'
)
}
@@ -43,7 +43,7 @@ pipeline {
credentialsId: env.GITEA_CREDENTIALS_ID
]]
])
echo "Repo cloné"
echo "Repository cloned"
}
}
@@ -51,47 +51,47 @@ pipeline {
steps {
script {
if (!fileExists('docker-compose.prod.yml')) {
error("docker-compose.prod.yml introuvable à la racine du repo !")
error("docker-compose.prod.yml not found at the repository root")
}
echo "docker-compose.prod.yml trouvé"
echo "docker-compose.prod.yml found"
}
}
}
stage('Deploy sur Portainer') {
stage('Deploy to Portainer') {
steps {
withCredentials([string(credentialsId: 'portainer-token', variable: 'PORTAINER_TOKEN')]) {
sh '''
COMPOSE_CONTENT=$(base64 -w 0 docker-compose.prod.yml)
# Récupère la liste des stacks
# Get the list of stacks
STACKS=$(curl -s -X GET "''' + env.PORTAINER_URL + '''/api/stacks" \
-H "X-API-Key: $PORTAINER_TOKEN")
# Cherche si la stack existe déjà
# Check whether the stack already exists
STACK_ID=$(echo "$STACKS" | jq -r '.[] | select(.Name == "''' + params.STACK_NAME + '''") | .Id')
if [ -n "$STACK_ID" ]; then
echo "🔄 Stack existante (ID: $STACK_ID), mise à jour..."
echo "Existing stack found (ID: $STACK_ID), updating..."
RESPONSE=$(curl -s -X PUT "''' + env.PORTAINER_URL + '''/api/stacks/$STACK_ID?endpointId=''' + env.PORTAINER_ENV_ID + '''" \
-H "X-API-Key: $PORTAINER_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"stackFileContent\": \"$COMPOSE_CONTENT\", \"prune\": true, \"pullImage\": true}")
else
echo "🚀 Création de la stack ''' + params.STACK_NAME + '''..."
echo "Creating stack ''' + params.STACK_NAME + '''..."
RESPONSE=$(curl -s -X POST "''' + env.PORTAINER_URL + '''/api/stacks/create/standalone/string?endpointId=''' + env.PORTAINER_ENV_ID + '''" \
-H "X-API-Key: $PORTAINER_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"name\": \"''' + params.STACK_NAME + '''\", \"stackFileContent\": \"$COMPOSE_CONTENT\"}")
fi
# Vérifie si la réponse contient une erreur
# Check whether the response contains an error
if echo "$RESPONSE" | jq -e '.message' > /dev/null 2>&1; then
echo "❌ Erreur Portainer : $(echo $RESPONSE | jq -r '.message')"
echo "Portainer error: $(echo $RESPONSE | jq -r '.message')"
exit 1
fi
echo "Stack déployée avec succès !"
echo "Stack deployed successfully"
'''
}
}
@@ -101,10 +101,10 @@ pipeline {
post {
success {
echo "🎉 Stack '${params.STACK_NAME}' déployée sur Portainer (tag: ${params.IMAGE_TAG})"
echo "Stack '${params.STACK_NAME}' deployed to Portainer (tag: ${params.IMAGE_TAG})"
}
failure {
echo "💥 Échec du déploiement de la stack '${params.STACK_NAME}'"
echo "Failed to deploy stack '${params.STACK_NAME}'"
}
}
}