Django                
            Ciągła integracja z Jenkins
        
        
            
    Szukaj…
Jenkins 2.0+ Pipeline Script
Nowoczesne wersje Jenkins (wersja 2.x) są dostarczane z „Build Pipeline Plugin”, który może być używany do koordynowania złożonych zadań CI bez tworzenia wielu połączonych zadań i umożliwia łatwe kontrolowanie wersji konfiguracji kompilacji / testowania.
Możesz zainstalować to ręcznie w zadaniu typu „Pipeline” lub, jeśli twój projekt jest hostowany na Github, możesz użyć „GitHub Organisation Folder Plugin”, aby automatycznie skonfigurować zadania dla ciebie.
Oto prosta konfiguracja dla stron Django, które wymagają zainstalowania tylko określonych modułów Pythona dla strony.
#!/usr/bin/groovy
node {
  // If you are having issues with your project not getting updated, 
  // try uncommenting the following lines.
  //stage 'Checkout'
  //checkout scm
  //sh 'git submodule update --init --recursive'
  stage 'Update Python Modules'
  // Create a virtualenv in this folder, and install or upgrade packages
  // specified in requirements.txt; https://pip.readthedocs.io/en/1.1/requirements.html
  sh 'virtualenv env && source env/bin/activate && pip install --upgrade -r requirements.txt'
  
  stage 'Test'
  // Invoke Django's tests
  sh 'source env/bin/activate && python ./manage.py runtests'
}
Jenkins 2.0+ Pipeline Script, Docker Containers
 Oto przykład skryptu potoku, który buduje kontener Docker, a następnie uruchamia w nim testy. Przyjmuje się, że runtests wejścia jest manage.py lub invoke / fabric z runtests komendą runtests . 
#!/usr/bin/groovy
node {
  stage 'Checkout'
  checkout scm
  sh 'git submodule update --init --recursive'
  imageName = 'mycontainer:build'
  remotes = [
    'dockerhub-account',
  ]
  stage 'Build'
  def djangoImage = docker.build imageName
  stage 'Run Tests'
  djangoImage.run('', 'runtests')
  stage 'Push'
  for (int i = 0; i < remotes.size(); i++) {
      sh "docker tag ${imageName} ${remotes[i]}/${imageName}"
      sh "docker push ${remotes[i]}/${imageName}"
   }
}