Enhancing Your Workflow with Jenkins
Creating Jenkins Projects
Free Style Projects
- Based on Manual Configurations.
Steps to Create Free Style Projects
Login to Jenkins dashboard
Tap on New item
Enter the item name, select the Freestyle project option, and then click OK.
You can add build steps and then click on Save.
From the project dashboard page, click on "Build Now" to run the project.
Build with success status will be shown here.
Clicking on any of the successful builds will open the Console output.
Handling Variables in Jenkins
Environment Variables
Environment variables are provided by Jenkins.
By clicking on "the list of available environment variables," we can view all the environment variables.
You can use environment variable as below
When executing the build, it is displayed in the console output.
User Defined Variable
This is created by the user.
To create a user-defined variable, go to the project configuration and select the "This project is parameterized" checkbox. Then, you can choose any parameter from the dropdown.
After selecting the parameter, you can add the name, default value, and description for the parameter.
When executing a build with a user-defined variable, "Build Now" changes to "Build with Parameters."
Clicking on "Build with Parameters" opens an input window where you can enter your desired parameter or keep the default parameter, then click on "Build."
After clicking on "Build," the build success status is displayed, and you can see the user-defined variable in the console output.
Pipeline Projects
Based on groovy scripts
To onboard the application to CICD process
Used to automate the builds and deployments and any process automation
pipeline composed of various stages
Stages are used to execute some task
Types of Pipeline
Declarative
A modern, clean, and easy-to-read and write syntax that simplifies pipeline creation
Scripted
Uses the Groovy language to create a pipeline as code, offering flexibility and extensibility
- We will use Declarative pipeline for our learning.
Creation of Pipeline project
From the Jenkins dashboard, click on "New Item," enter the item name, select "Pipeline," and then click "OK."
The configuration page will open, where you can write your pipeline scripts. Then, click on "Apply" and "Save."
In pipeline script box can select anything from dropdown.
Click on "Build Now" from the project dashboard to view the output console.