Advertisement
QualibreInfo

django jenkins pipeline

May 31st, 2023 (edited)
1,986
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.58 KB | None | 0 0
  1. pipeline {
  2.     agent any
  3.     environment {
  4.         AUTHOR = 'Guillaume Rémy'
  5.         PURPOSE    = 'This is a sample Django app'
  6.         LIFE_QUOTE = 'The greatest glory in living lies not in never falling, but in rising every time we fall.'
  7.     }
  8.     stages {
  9.         stage('Checkout') {
  10.             steps {
  11.                 // Checkout your source code repository
  12.                 git branch: 'main',
  13.                     url: 'https://gitlab.com/<username>/python-django-simple.git'
  14.             }
  15.         }
  16.         stage('Setup') {
  17.             steps {
  18.                 // Set up your virtual environment or any other dependencies
  19.                 sh 'python3 -m venv venv'
  20.             }
  21.         }
  22.         stage('Install Dependencies') {
  23.             steps {
  24.                 // Install required dependencies
  25.                 sh '. venv/bin/activate && pip3 install -r requirements.txt'
  26.             }
  27.         }
  28.         stage('Test') {
  29.             steps {
  30.                 // Run your Django tests
  31.                 sh '. venv/bin/activate && python3 manage.py test'
  32.             }
  33.         }
  34.         stage('Build') {
  35.             steps {
  36.                 // Build your Django application
  37.                 sh 'docker build -t django-simple-app .'
  38.             }
  39.         }
  40.         stage('Deploy') {
  41.             steps {
  42.                 // Deploy your Django application
  43.                 sh 'docker rm -f django-sample-app || true'
  44.                 sh 'docker run --name django-sample-app -d -p 8000:8000 -it -e AUTHOR -e PURPOSE -e LIFE_QUOTE django-simple-app'
  45.             }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement