Introduction to Jenkins
- jesus martinez

- Sep 15, 2024
- 3 min read
Jenkins is an open-source automation server that helps automate parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery (CI/CD). It is highly extensible, with a large number of plugins available to integrate with various tools and platforms.
Key Features of Jenkins:
1. Extensibility: Jenkins supports a wide range of plugins for different tasks and integrations.
2. Distributed Builds: Jenkins can distribute build tasks across multiple machines.
3. Pipeline as Code: Define your build, test, and deploy processes in code.
4. Easy Installation: Jenkins is easy to set up and configure.
How Jenkins Works
1. Job Configuration:
o A job in Jenkins is a task or set of tasks like building code, running tests, or deploying applications.
o You configure a job by specifying the tasks and defining when and how often they should run.
2. Source Code Management (SCM):
o Jenkins integrates with SCM tools like Git, SVN, and Mercurial.
o It can pull code from repositories to build and test automatically.
3. Build Triggers:
o Jobs can be triggered by various means, such as code changes (via webhooks), scheduled intervals (cron jobs), or manual triggers.
4. Build Execution:
o Jenkins executes the defined build steps, which can include compiling code, running tests, and packaging applications.
o It supports various build tools like Maven, Gradle, and Ant.
5. Post-Build Actions:
o After the build, Jenkins can perform additional actions like archiving artifacts, notifying stakeholders, or deploying applications.
o It can also integrate with tools like Slack, email, or Jira for notifications.
6. Plugins:
o Jenkins has a robust plugin ecosystem. Plugins can add new functionality or integrate Jenkins with other tools and platforms.
o Examples include Docker, Kubernetes, AWS, and more.
Using Jenkins: A Step-by-Step Guide
1. Installation:
Prerequisites:
Jenkins requires Java. Ensure Java is installed on your system.
Installing Jenkins:
On Windows:
Download the Windows installer from the Jenkins website and run the setup.
On macOS:
Use Homebrew: brew install jenkins-lts
On Linux:
Use package managers like apt or yum, or download the .war file from the Jenkins website and run it using java -jar jenkins.war.
2. Initial Setup:
Access Jenkins:
Once installed, Jenkins runs on http://localhost:8080.
Unlock Jenkins:
During the initial setup, Jenkins will prompt you for an administrator password, found in the initialAdminPassword file.
Install Suggested Plugins:
Jenkins will recommend a set of plugins. Installing these will cover most basic needs.
Create First Admin User:
Set up your first administrative user with credentials.
3. Creating a Job:
Create a New Job:
Go to Jenkins dashboard, click on "New Item", name your job, and select the job type (e.g., Freestyle project).
Configure the Job:
Source Code Management:
Specify the repository URL and credentials if needed.
Build Triggers:
Set up how and when the job should be triggered (e.g., poll SCM, build periodically).
Build Steps:
Add build steps, like executing shell commands, running build tools (Maven, Gradle), or invoking other jobs.
Post-Build Actions:
Define actions like archiving artifacts, sending notifications, or triggering other jobs.
4. Defining Pipelines:
Pipeline as Code:
Jenkins Pipeline allows defining the entire build process in a Jenkinsfile, written in Groovy.
Creating a Pipeline Job:
Create a new item, choose "Pipeline", and define the pipeline script.
5. Running and Monitoring Jobs:
Run Jobs:
Trigger the job manually or wait for it to be triggered by configured triggers.
Monitor Jobs:
View job progress and logs in real-time via the Jenkins dashboard.
Check build history and artifact archives for previous runs.
6. Using Plugins:
Install Plugins:
Go to "Manage Jenkins" > "Manage Plugins".
Browse and install necessary plugins to extend Jenkins functionality.
Configure Plugins:
After installation, configure plugins via "Manage Jenkins" or within job configurations.





Comments