Introduction
Jenkins, the stalwart of continuous integration and deployment, is here to simplify your development life! In this blog post, we'll embark on a journey to create a basic Jenkins project using a Freestyle job. Buckle up, and let's dive into the world of automation.
Get ready as we break down each section of the Freestyle project configuration to empower your Jenkins journey! ๐ ๏ธ
Before we dive into the details, ensure you have Jenkins installed on your AWS Ubuntu EC2 instance. If not, check out this step-by-step Jenkins setup tutorial to get started.
Setting the Stage
General Section ๐
In the Jenkins job configuration, start by clicking on New Item or New Job. Choose the Freestyle project and give your project a name. This is the first step in laying the foundation for your CI/CD pipeline.
Description ๐: Provide a brief description of your project, setting the stage for what it's all about.
Discard Old Builds ๐๏ธ: Keep things tidy by automatically discarding old builds after a set number, ensuring your workspace stays clutter-free.
GitHub Project ๐: If your code resides on GitHub, link your project to its GitHub counterpart for seamless integration.
This Project is Parameterized ๐๏ธ: Add flexibility by enabling parameterization, allowing users to input values during the build process.
Throttle Builds โ๏ธ: Control the number of concurrent builds, preventing resource overload.
Execute Concurrent Builds if Necessary ๐ฆ: Allow multiple builds of the project to run simultaneously if needed.
Source Code Management ๐ ๏ธ
None ๐: If you're not using any version control system, select "None." Otherwise, choose your preferred SCM, such as Git.
Git ๐: If you're using Git, provide the repository URL and specify the branches to build.
Build Triggers ๐
Trigger Builds Remotely ๐: Enable remote triggering of builds for automation purposes.
Build After Other Projects Are Built ๐ง: Specify projects that should trigger a build upon successful completion.
Build Periodically โฐ: Set up scheduled builds for regular, automated releases.
GitHub Hook Trigger for GITScm Polling ๐ฃ: Integrate with GitHub to trigger builds on code changes.
Poll SCM ๐: Periodically poll the source code repository for changes and trigger builds when necessary.
Build Environment โ๏ธ
Delete Workspace Before Build Starts ๐งน: Ensure a clean slate by deleting the workspace before initiating a new build.
Use Secret Text(s) or File(s) ๐: Securely pass sensitive information to the build process.
Add Timestamps to the Console Output ๐: Keep track of when things happen by adding timestamps to the console output.
Inspect Build Log for Published Build Scans ๐ต๏ธ: If using Gradle, inspect the build log for published build scans.
Terminate a Build if It's Stuck ๐จ: Prevent Jenkins from hanging indefinitely if a build gets stuck.
Build Steps ๐ป
Execute Shell ๐: The moment of truth! Define shell commands to be executed during the build process. For practice, try a simple
mkdir
command to create a directory.Command ๐: Enter the shell commands you want Jenkins to execute, like:
mkdir my_workspace
Advanced Settings โ๏ธ
The Advanced section houses additional settings for customizing your build environment further. Explore these options as you become more comfortable with Jenkins.
Post-build Actions ๐
Congratulations on reaching the finale! The Post-build Actions section is where the magic happens after the build completes:
Archive the Artifacts ๐๏ธ: Preserve essential files after a successful build.
Publish JUnit Test Result Report ๐: Share detailed test reports.
Email Notification ๐ง: Keep your team in the loop by configuring email notifications.
Publish HTML Reports ๐: Showcase HTML reports generated during the build.
Deploy to Container ๐ข: If applicable, deploy your artifacts to a web container.
Trigger Parameterized Build on Other Projects ๐๏ธ: Orchestrate a series of related builds.
Git Publisher ๐ค: Push changes back to the repository or update Git tags.
Join Trigger ๐: If using the "Join" plugin, specify conditions for joining multiple builds.
Conditional Actions Based on Build Status ๐ญ: Execute actions based on the build result, ensuring flexibility in your CI/CD pipeline.
Conclusion
You've just taken the first steps in setting up your Jenkins project! ๐ The road ahead holds endless possibilities for automation and streamlining your development workflow. Stay tuned for more Jenkins adventures as you explore advanced features and build robust pipelines.
Happy building! ๐๐ ๏ธ๐ฉโ๐ป๐จโ๐ป