Files
sirh/Jenkinsfile

51 lines
1.3 KiB
Plaintext
Raw Normal View History

2026-04-30 12:47:18 +00:00
pipeline
{
2026-04-30 13:17:43 +00:00
agent any
2026-05-06 11:19:30 +00:00
options {
// This is required if you want to clean before build
skipDefaultCheckout(true)
}
2026-04-30 14:45:35 +00:00
2026-05-04 09:51:25 +00:00
environment
{
SUDO_PASSWORD = credentials('sudo-password')
}
2026-04-30 12:47:18 +00:00
stages
{
2026-04-30 14:50:58 +00:00
stage ( 'checkout' )
{
steps
{
2026-04-30 14:56:06 +00:00
sh 'echo "Debut du pipeline"'
2026-05-06 11:19:30 +00:00
cleanWs()
2026-04-30 14:50:58 +00:00
checkout scm
}
}
2026-04-30 14:45:35 +00:00
stage ( 'Deploiement' )
2026-04-30 12:47:18 +00:00
{
2026-04-30 14:45:35 +00:00
when { branch 'main' }
steps {
sh '''
2026-05-04 12:22:15 +00:00
cd /var/www/sirh
echo $SUDO_PASSWORD | sudo -S chown -R jenkins:jenkins /var/www/sirh
2026-05-06 11:19:30 +00:00
git fetch origin main
git reset --hard origin/main
2026-04-30 15:01:54 +00:00
python3 -m venv venv
2026-04-30 15:43:00 +00:00
. venv/bin/activate
2026-04-30 14:45:35 +00:00
pip install -r requirements.txt
2026-05-06 11:19:30 +00:00
2026-04-30 14:45:35 +00:00
python manage.py makemigrations
python manage.py migrate
2026-05-11 15:27:50 +00:00
python manage.py collectstatic --noinput
2026-05-06 11:19:30 +00:00
2026-05-04 13:44:41 +00:00
echo $SUDO_PASSWORD | sudo -S chown -R www-data:www-data /var/www/sirh
2026-04-30 14:45:35 +00:00
echo "Deploiement reussi"
2026-05-06 11:19:30 +00:00
echo $SUDO_PASSWORD | sudo -S supervisorctl restart sirh
2026-04-30 14:45:35 +00:00
'''
}
2026-04-30 12:47:18 +00:00
}
2026-04-30 13:11:14 +00:00
}
2026-04-30 12:47:18 +00:00
}