add docker files
This commit is contained in:
parent
2d71ddc099
commit
49dc85e416
@ -23,35 +23,30 @@ test-job:
|
|||||||
deploy-job:
|
deploy-job:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
script:
|
script:
|
||||||
- set -x
|
|
||||||
- echo "Déploiement sur Portainer..."
|
|
||||||
- echo "Utilisation du token API de Portainer..."
|
|
||||||
|
|
||||||
# Vérifier que la variable PORTAINER_API_KEY est définie (sans l'afficher)
|
|
||||||
- if [ -z "$PORTAINER_API_KEY" ]; then echo "Erreur : La variable PORTAINER_API_KEY n'est pas définie."; exit 1; fi
|
|
||||||
|
|
||||||
# Vérifier que PORTAINER_URL et STACK_ID sont définis
|
|
||||||
- if [ -z "$PORTAINER_URL" ]; then echo "Erreur : La variable PORTAINER_URL n'est pas définie."; exit 1; fi
|
|
||||||
- if [ -z "$STACK_ID" ]; then echo "Erreur : La variable STACK_ID n'est pas définie."; exit 1; fi
|
|
||||||
|
|
||||||
# Optionnel : Afficher les variables (sans afficher les données sensibles)
|
|
||||||
- echo "PORTAINER_URL : $PORTAINER_URL"
|
|
||||||
- echo "STACK_ID : $STACK_ID"
|
|
||||||
|
|
||||||
- echo "Déploiement de la stack sur Portainer..."
|
|
||||||
|
|
||||||
# Exécuter la commande curl avec l'option -v pour avoir plus de détails
|
|
||||||
- |
|
- |
|
||||||
|
set -x
|
||||||
|
echo "Déploiement sur Portainer..."
|
||||||
|
echo "Utilisation du token API de Portainer..."
|
||||||
|
|
||||||
|
# Vérification des variables d'environnement
|
||||||
|
if [ -z "$PORTAINER_API_KEY" ]; then echo "Erreur : PORTAINER_API_KEY non définie."; exit 1; fi
|
||||||
|
if [ -z "$PORTAINER_URL" ]; then echo "Erreur : PORTAINER_URL non définie."; exit 1; fi
|
||||||
|
if [ -z "$STACK_ID" ]; then echo "Erreur : STACK_ID non définie."; exit 1; fi
|
||||||
|
|
||||||
|
# Affichage des variables (sauf les sensibles)
|
||||||
|
echo "PORTAINER_URL : $PORTAINER_URL"
|
||||||
|
echo "STACK_ID : $STACK_ID"
|
||||||
|
|
||||||
|
echo "Déploiement de la stack sur Portainer..."
|
||||||
|
|
||||||
RESPONSE=$(curl -v -X PUT \
|
RESPONSE=$(curl -v -X PUT \
|
||||||
-H "Authorization: Bearer $PORTAINER_API_KEY" \
|
-H "Authorization: Bearer $PORTAINER_API_KEY" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"Prune": true}' \
|
-d '{"Prune": true}' \
|
||||||
http://$PORTAINER_URL/api/stacks/$STACK_ID/deploy 2>&1)
|
http://$PORTAINER_URL/api/stacks/$STACK_ID/deploy 2>&1)
|
||||||
|
|
||||||
# Extraire le code HTTP de la réponse
|
|
||||||
HTTP_CODE=$(echo "$RESPONSE" | grep "< HTTP/" | awk '{print $3}')
|
HTTP_CODE=$(echo "$RESPONSE" | grep "< HTTP/" | awk '{print $3}')
|
||||||
|
|
||||||
# Afficher la réponse pour le débogage
|
|
||||||
echo "Réponse de l'API :"
|
echo "Réponse de l'API :"
|
||||||
echo "$RESPONSE"
|
echo "$RESPONSE"
|
||||||
|
|
||||||
@ -60,5 +55,4 @@ deploy-job:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- echo "Déploiement terminé avec succès."
|
echo "Déploiement terminé avec succès."
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user