Step-by-Step Guide to Your First Jenkins Project

Sagar ShahSagar Shah
4 min read

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! ๐Ÿš€๐Ÿ› ๏ธ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

11
Subscribe to my newsletter

Read articles from Sagar Shah directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sagar Shah
Sagar Shah

๐Ÿš€ Sagar Shah ๐Ÿš€ ๐Ÿ’ป DevOps Engineer ๐Ÿ’ก ๐ŸŒ Automating the digital universe, one script at a time โš™๏ธ ๐Ÿ“š Passionate learner and tech enthusiast ๐Ÿค“ โ˜๏ธ Cloud explorer, making servers dance in the cloud ๐ŸŒฅ๏ธ ๐Ÿ› ๏ธ Building bridges between development and operations ๐ŸŒ‰ ๐Ÿ“– Sharing insights and knowledge on all things DevOps ๐Ÿ“ข ๐ŸŒŸ Let's transform the world of IT together! โœจ