- Jenkins: Jenkins configurations and scripts
- Docker Image: Docker images used in the project
- Static Code Analysis: Static code analysis tools and results
- Knowledge: Documentation and knowledge base
- Architecture: Architectural designs and diagrams
- Test Cases with Pipeline Code: Test cases related to the pipeline
- Docker: Docker-related information and examples
- Allure: Allure reporting for tests
- Asserts: Assertions for tests
- Brightskies_CI_Jenkins Image: CI Jenkins image configurations
- Docker Swarm: Docker Swarm configurations and examples
- Jenkins_Ubuntu: Jenkins configurations for Ubuntu
- Simple Docker Commands: Basic Docker command examples
- Git Extension: Git extensions and usage
- Integration Testing: Integration testing strategies
- PyTest: PyTest configuration and examples
- Integration & Unit Testing & Reporting: Details on integration and unit testing with reporting
- PyTest: PyTest configuration and examples
- Jenkins: Additional Jenkins documentation
- Errors & Solutions: Common errors and their solutions
- Integrate GTest: Integration of GTest in Jenkins
- Jenkins Email Notification: Email notification setup in Jenkins
- Jenkins Agent: Configuration and setup of Jenkins agents
- Jira Integration: Integration of Jira with the project
- Import CSV: CSV import configurations
- ngrok: Setup and usage of ngrok
- Prerequisites: Required tools and software
- Pytest: Configuration and usage of Pytest
- Reporting: Reporting tools and setups
- Allure: Allure setup and usage
- Unit Testing: Unit testing strategies and examples
- Code Coverage: Code coverage configurations and tools
- GTest: GTest configurations and usage
- Static Code Analysis: Static code analysis configurations
- Architecture: Architectural designs and diagrams
This guide will walk you through setting up the project locally using Docker and Jenkins. The setup includes volume mapping to ensure data persistence and cloning the repository into the Jenkins home directory. Additionally, we'll cover how to install necessary plugins and tools in Jenkins.
-
Docker Desktop:
- Download and install Docker Desktop from https://www.docker.com/.
- After installation, sign in to Docker Desktop and ensure it is running.
-
Git installed on your system.
First, clone the repository to your local machine:
git clone https://github.com/AhmedSamymoh/CI-CD-Jenkins.git
cd CI-CD-JenkinsTo build the Jenkins Docker image, run the following command:
cd '.\Docker Image\'docker build -t brightskies_ci_jenkins:latest .Start the Jenkins container using Docker Compose:
mkdir C:/Jenkin_Workspacedocker-compose up- the docker compose will:
- Start the Jenkins container.
- Mount the host directory
C:/Jenkin_Workspaceto/jenkins_homein the container for persistent storage. - Map port
8082on your host to port8080in the container (Jenkins UI). - Map port
50000for Jenkins agent communication.
-The docker-compose.yml file defines the following volume mapping:
Copy
version: '3.8'
services:
jenkins:
image: brightskies_ci_jenkins
ports:
- "8082:8080"
- "50000:50000"
volumes:
- C:/Jenkin_Workspace:/jenkins_home- Volume Mapping: The C:/Jenkin_Workspace directory on your host is mapped to /jenkins_home in the container. This ensures that all Jenkins data (jobs, configurations, plugins, etc.) is stored persistently on your host machine.
- Data Persistence: Jenkins data will persist even if the container is stopped or restarted.
- Easy Access: You can directly access Jenkins data from your host machine.
-
Access Jenkins:
-
Open your browser and navigate to:
http://localhost:8082 -
Unlock Jenkins using the initial admin password.
-
You can find this
passwordin the Jenkins logs or at:C:/Jenkin_Workspace/secrets/initialAdminPassword
-
-
Add Jenkins Credentials:
- Navigate to Manage Jenkins β Manage Credentials.
- Under Stores scoped to Jenkins, click on Global credentials.
- Click Add Credentials and enter:
- Kind: Username with password
- Scope: Global (Recommended)
- Username:
<your-username> - Password:
<your-password> - ID:
git-credentials - Description:
Git authentication for Jenkins
- Save the credentials.
After unlocking Jenkins, you will be prompted to install plugins. Install the following recommended plugins:
- Git Plugin β Integrates Jenkins with Git repositories.
- GitLab Plugin β Required if using GitLab for version control and CI/CD.
- Allure Jenkins Plugin β Generates Allure Test Reports for test automation.
- GitHub Pull Request Builder Plugin β Triggers builds for pull requests from GitHub.
After unlocking Jenkins, navigate to:
-
Manage Jenkins β Plugins Manager β Available Plugins
-
Search for the plugins and install them.
-
Configure Tools:
-
Go to Manage Jenkins > Global Tool Configuration.
-
Configure tools like Git, Docker, and any other dependencies required for your project.
-
Clone the repository into C:/Jenkin_Workspace (host) or /var/jenkins_home (container):
# Inside Jenkins Container
docker ps # Get container ID or name
docker exec -it <container_id_or_name> bashcd /var/jenkins_home
git clone https://github.com/AhmedSamymoh/CI-CD-Jenkins.gitcd /var/jenkins_home/CI-CD-Jenkins
ls- Expected output:
root@bf366f7f9989:/var/jenkins_home/CI-CD-Jenkins# ls
'Docker Image' Jenkins Jira Knowledge LICENSE Ngrok README.md Static_Code_Analysis
- Edit jira.sh , Visit
Jira README.mdβοΈ
JIRA_USER="your_email"
JIRA_API_TOKEN="your_token"
JIRA_URL="your_jira_url" - Making
Misra_src_check.shexecutable
cd /var/jenkins_home/CI-CD-Jenkins/Static_Code_Analysis
chmod 777 Misra_src_check.sh- Update
webhook.py, VisitNgrok README.mdβοΈ
cd /var/jenkins_home/CI-CD-Jenkins/Ngrok
vim webhook.py
REPO_OWNER = "YourUserName"
REPO_NAME = "Repo"
GITHUB_TOKEN = "*******Token*******" -
Once Jenkins is up and running, verify the setup by:
-
Creating a new Jenkins job or pipeline.
-
Configuring the job to use the cloned repository.
-
Running a build to ensure everything is working correctly.
-
Using Jenkins Pipelines, create a Jenkinsfile in your repository. Hereβs an example:
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building the project...'
}
}
stage('UnitTesting') {
steps {
echo 'Running tests...'
}
}
stage('Sprint Release Notes') {
steps {
echo 'Sprint Release Notes...'
}
}
}
}This pipeline defines three stages: Build, Test, and Deploy. Customize it according to your project requirements.
To securely interact with private repositories, Docker Hub, or other services, configure credentials in Jenkins.
- Go to Manage Jenkins β Manage Credentials.
- Select (global) under Stores scoped to Jenkins.
- Click Add Credentials β Select Username with password or SSH Key.
- Enter your GitHub username and personal access token.
- Save the credentials.
- Navigate to Manage Jenkins β Manage Credentials.
- Click Add Credentials β Select Username with password.
- Enter your Docker Hub username and password.
- Save the credentials.
