├── .gitattributes ├── .gitignore ├── .idea └── .gitignore ├── Jenkinsfile └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.xml 3 | *.iml 4 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent any 3 | 4 | stages { 5 | stage('Checkout') { 6 | steps { 7 | checkout([$class: 'GitSCM', branches: [[name: 'main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/vastevenson/pytest-intro-vs.git']]]) 8 | } 9 | } 10 | stage('Build') { 11 | steps { 12 | git branch: 'main', url: 'https://github.com/vastevenson/pytest-intro-vs.git' 13 | sh 'python3 ops.py' 14 | } 15 | } 16 | stage('Test') { 17 | steps { 18 | sh 'python3 -m pytest' 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Jenkins Pipeline for Python Build and Test Stages 2 | * Link to YouTube video overview of this process: https://youtu.be/6njM8g5hKuk 3 | ### Installation with Docker 4 | * Install Docker on your local machine. 5 | * Run this command: `docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts-jdk11` 6 | * Write down the password that's created for you during this first time set up process: like `8458e513eacd41d8875ca3253f47d3a0` 7 | * Go to `localhost:8080` and you should be prompted for this password 8 | * Follow the steps in this video: https://youtu.be/6njM8g5hKuk to create the pipeline 9 | * The link to the public Github repo that was built and tested in the video is: https://github.com/vastevenson/pytest-intro-vs 10 | * While the docker container is running, run cmd: `docker ps` to see what containers are running - copy the container ID for Jenkins, like `8f7c957e19fd` 11 | * Run command: `docker exec -it -u 0 8f7c957e19fd /bin/bash` to open an interactive terminal within the Docker Container as root (user 0) 12 | * Run command: `apt-get update` and `apt-get install python3` and `apt-get install python3-pip` to install Python3 and pip within the Docker container 13 | * Run `pip install pytest` to install the pytest package that actually runs the unit/integ tests during your test stage within the pipeline 14 | --------------------------------------------------------------------------------