Menu
  • Home
  • About Me
  • Blog
  • Github
  • LinkedIn

Jenkins Simple Python CI Pipeline

January 24, 2022

I’m going to create CI (Continuous Integration) Pipelines for Python project. The pipeline will include build, test, packaging and artifact storage. Furthermore, the pipeline will be automatically triggered when the source code changes (A push to a project in GitLab should trigger the build job).

Create Jenkins Job and Integration with GitLab

GitLab:

Create a new project called point and make it an internal repository.

Push the Python code. and create an Access Token for your account (User Dropdown -> Settings -> Access Tokens)

Give it a name of jenkins_svc

Check the read_repository and write_repository scopes

Create the personal access token and save the token value

Login to Jenkins

Create a new build job:

  • Select New Item
  • Name it “Point”
  • Select Freestyle Project
  • Press OK

Configure the build job:

  • In Source Code Management, select Git
  • Repository URL is the https URL of you Point project from GitLab (i.e., clone URL)
  • You should see an error that it cannot connect to the repo
  • Select Add -> Credentials and enter your Access Token name and Password. Give it an ID of jenkins_svc.
  • The error should go away if the Access Token is correct
  • Press Save

Run the build job:

  • Select Configure
  • Under Build, select Add Step -> Execute Shell
  • Add the following command:
python3 -m unittest test_point_manager

Press Save.

SSH into Jenkins VM and add the following to your dockerfile

USER root
...
RUN apt-get update
RUN apt-get install -y python3 python3-pip
RUN pip3 install SQLAlchemy
RUN pip3 install --upgrade pip

Run the docker stop, build and start command from Step 3 to re-build and re-start your Jenkins
image.

Re-run the build job. It should now be successful.
View the Console Output to make sure the unittests have run and all passed.
To see the Console Output, select on the build job in the History and the Console Output
option should appear on the left side

The Output should be like this:

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts
  • ChinguTalkBot v0.1.0: Setting up AWS Cognito with CDK for User Authentication
  • Phoenix & Elixir: Fix PostgreSQL connection refused
  • Demo: Git Log with Shell script to create a release notes
  • Metasploit
  • CyberSecurity Lab – Online Password Attack

Archives
  • March 2024
  • May 2023
  • April 2023
  • February 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
Categories
  • Amazon Interview (3)
  • Ansible (3)
  • AWS (9)
  • Azure (9)
  • Certification (2)
  • ChinguTalkBot Project (1)
  • cybersecurity (3)
  • Data analytics (6)
  • Demo Videos (6)
  • Docker (5)
  • Git (1)
  • GitLab (1)
  • Golang (3)
  • JavaScript (2)
  • Jenkins (4)
  • PowerShell (1)
  • Python (10)
  • Terraform (11)
  • Uncategorized (9)

©2025 | Powered by WordPress and Superb Themes!