Jenkins Freestyle Project

Jenkins Freestyle Project

In my previous blog post, we delved into the fundamentals of Jenkins, understanding its importance in the world of continuous integration and continuous deployment (CI/CD).

We explored the basics, setting up Jenkins, and initiating our first Jenkins job. Today, we're taking a step further by focusing on Jenkins Freestyle Projects, an integral aspect of Jenkins that provides us with a powerful and flexible way to automate their build and deployment processes.

You can check my previous blog here: "Getting Started with Jenkins".

Understanding CI/CD

Before we jump into Freestyle Projects, let's briefly revisit the concept of Continuous Integration and Continuous Deployment (CI/CD).

CI/CD is a software engineering practice that aims to enhance the development process by enabling automation at various stages.

Continuous Integration involves merging code changes into a shared repository multiple times a day, ensuring that changes do not conflict.

On the other hand, Continuous Deployment, automates the deployment process, allowing code changes to be automatically deployed to production after passing automated tests.

What is a Build Job?

In a Jenkins build job, you define how a particular task or step in building an application should be automated. This could involve tasks such as collecting necessary components, compiling code, storing it for future reference, modifying code, and checking its functionality in various settings before finally deploying it.

A build job in Jenkins is like having a helpful assistant who does all the hard work for you when you're creating software. Imagine it as a step-by-step recipe for baking a cake. Each step, from mixing ingredients to baking, is crucial to make sure the cake turns out just right.

Similarly, in Jenkins, a build job consists of these carefully ordered steps that automatically build, test, and deploy your software. You can set it up to run at specific times, like a timer on an oven, or start it whenever you need, just like baking whenever you crave a homemade treat!

Jenkins offers a variety of build job types, including:

  1. Freestyle projects: These are the simplest form of build jobs, enabling you to outline the specific steps to be executed during the build process.

  2. Pipelines: More advanced than freestyle projects, pipelines allow you to articulate the build steps using a structured, declarative syntax.

  3. Multi-configuration projects: These projects enable the creation of multiple builds for the same project, each with unique configurations.

  4. Folders: Folders serve as a means to categorize and arrange your build jobs systematically.

  5. Multibranch pipelines: These pipelines are designed around branches within a Git repository, enabling tailored build processes for different branches.

  6. Organization folders: These folders aid in organizing your build jobs based on the respective organizations.

In this blog post, we'll be exploring the Freestyle Projects. Let's dive into what exactly a freestyle project is.

What is a Freestyle Project?

A Freestyle Project in Jenkins is a user-configured project type that offers a flexible way to define and automate various tasks. Unlike other project types, Freestyle Projects do not require a predefined build configuration. Instead, they allow developers to specify build steps, post-build actions, and triggers according to their project requirements. This flexibility makes Freestyle Projects suitable for a wide range of tasks, from simple builds to complex deployment pipelines.

Here are several tasks that can be accomplished while working with a freestyle project in Jenkins:

  1. Building Software Projects: Freestyle projects are versatile and can be employed to build various types of applications, including web, mobile, and desktop applications.

  2. Running Automated Tests: Freestyle projects allow you to automate the testing process for your software projects, ensuring their functionality and reliability.

  3. Deploying Software: Freestyle projects facilitate the deployment of software projects to production environments, ensuring smooth transitions to live systems.

  4. Collecting Build Metrics: Freestyle projects enable the collection of essential metrics about the build process. These metrics serve as valuable data for enhancing the efficiency and effectiveness of your builds.

  5. Integration with Other Tools: Freestyle projects can seamlessly integrate with a range of tools, including version control systems, continuous integration servers, and continuous delivery servers, enhancing the overall development workflow.

Task-01

Create Jenkins Freestyle Project for ToDoApp.

  • Log in to Jenkins and open the Dashboard

  • Create a “New Item”

  • Select “Freestyle project” and give a name to your project.

  • Click on the “OK” button to create the project.

  • Within the project configuration, provide project specifics like the source code management system, build triggers, and build actions. If you're working with a GitHub project, include the repository URL of your GitHub project.

  • In the “Source Code Management” section,add your repository Link.

  • Specify the branch where the source code is present.

  • In the “Build” section of the project, add a build step to run the “docker build” command to build the image for the container.

  • Click on Save Button.

  • You can initiate the project's build process by clicking the "build now" tab manually.

  • After a successful build, you can navigate to the console output and review the build results.

  • At the last line of the Console Output, you'll notice the message "Finished: Success." This indicates the successful completion of our build.

  • We can confirm the accessibility of the ToDo list application at host_IP:8000.

Task-02

  • Set up a Jenkins project to execute the "docker-compose up -d" command, initiating multiple containers as specified in the compose file.

  • Create a docker-compose.yml file within your project directory to define the container configurations.

  • Within the project's "Build" section, incorporate a build step by adding the "docker-compose down" command to halt and remove containers specified in the compose file. Follow it with the "docker-compose up -d" command.

  • Establish a cleanup step in the Jenkins project to execute the "docker-compose down" command, effectively stopping and removing the containers outlined in the compose file.

  • Save the configurations and build the project.

  • Now we can try accessing the application on the browser at host_IP:8000.

Conclusion

In conclusion, understanding Jenkins Freestyle Projects opens up a world of possibilities for developers seeking to automate their CI/CD pipelines. Its flexibility empowers developers to tailor their automation workflows precisely to their project needs, enhancing efficiency and reliability.

I hope this blog post has shed light on the significance of Jenkins Freestyle Projects in the CI/CD landscape.

Your feedback is invaluable to me; it helps me improve my content and deliver more relevant information to you.

Feel free to connect with me on LinkedIn. Let’s stay connected and continue our learning journey together!