Giter VIP home page Giter VIP logo

jenkins_cicd_python_to_docker's Introduction

jenkins_cicd_python_to_docker

Build and deploy jenkins container (that will serve also as the agent) that runs the python script located in the master branch, on every push request.

To start everything, just run "docker compose up" in the repository. For configuring the jenkins and github, and creating the job itself, follow the "Usage" guide.

Structure

jenkins_cicd_python_to_docker/
|
├── app/                    # app folder
|   ├── Dockerfile          # python dockerfile
|   ├── __init__.py         # 
|   ├── main.py             # the solution
|   └── test_main.py        # solution unit test
|
├── images/                 # images for the readme file
├── .gitignore              # 
├── Dockerfile              # jenkins dockerfile
├── Jenkinsfile             # jenkinsfile for the pipeline
├── README.md               # readme file
├── casc.yaml               # configuration for jenkins
├── docker-compose.yml      # docker-compose to build the images and run the containers
├── jenkins-cli.jar         # jenkins-cli
├── jenkins_plugins.txt     # the jenkins plugins that will be installed
└── test.xml                # xml of the job

Getting Started

prerequisites

First, make sure you have docker and docker-compose. If you want to clone this repo, download and use git if you haven't already. The dockerfile pulls image from dockerhub so also check you are connected to the internet \ to your image repo (if its your private image repo, make sure you have the image that is pulled with the same name).

Usage

  1. Clone the repo
git clone https://github.com/Sh4peSh1fter/jenkins_cicd_python_to_docker.git
  1. Run the docker-compose to deploy the containers. Make sure you are in the same folder with the docker-compose.yml.
cd jenkins_cicd_python_to_docker
docker compose up
  1. After the docker-compose finished successfuly, visit http://127.0.0.1:8080/, and finish the jenkins setup.
  2. Create new pipeline (the name doesn't metter) step 4 - create new pipeline
  3. In the "General" section, check the "GitHub project", and enter your project's url ("https://github.com/Sh4peSh1fter/jenkins_cicd_python_to_docker/" for this example) step 5 - enter github project url
  4. In the "Pipeline" section, pick the "pipeline script from SCM". Under that pick "Git" as your SCM and enter the git repo you want to be connected with in the "repositoriy URL". If the repo is public you can leave the "credentials" as none. Dont forget to save. step 7 - configure SCM

Now we need to configure the connection to the github for the jenkins.

  1. Under the "manage jenkins" option, select "configure system". There, in the "GitHub" section, select your credentials for github if you dont have already. step 8 - configure jenkins github connection
  2. In the same page, go to the "GitHub Pull Request Builder" section. there select the same credentials for your github, and check "Auto-manage webhooks".

Uh. The last part of the setup. Configuring the Github webhook that will be triggered only on pull (merge) requests.

  1. In the github repo, go to the settings > webhooks. There add a new webhook. The payload url should be in this format: "http://<jenkins_ip>:8080/ghprbhook/". In the "Content type" select "application/json", and on the events that will trigger the webhook, select "let me select individual events" > "pull requests". step 10 - configure github webhook

jenkins_cicd_python_to_docker's People

Contributors

sh4pesh1fter avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.