Introduction
Jenkins offers powerful features like parameterization, allowing developers to customize and configure jobs with specific inputs. In this guide, we'll explore different parameter types, change Jenkins port settings, and address common issues related to server crashes and job deletion.
Jenkins Parameters
Parameters enable flexibility and customization in Jenkins jobs. Here are some common parameter types:
Choice: For selecting options from a list (e.g., environments: dev, test, uat, prod).
String: For passing single-line inputs.
Multi-line String: To pass multi-line inputs.
Boolean: For true or false options.
File: To handle file inputs.
Example Configuration
Create a CI job.
Configure > This project is parameterized.
Add Parameter > Choice > Name:
env
, Choices:dev,test,uat,prod
.
Additional Notes
For multiple options, use the "Choice" parameter.
String, Multi-line String, Boolean, and File parameters offer specific use cases.
Changing Jenkins Port
To change the default port (8080) of Jenkins, follow these steps:
Edit the Jenkins service file:
sudo vim /usr/lib/systemd/system/jenkins.service
Change the port number (e.g., from 8080 to 8090).
Reload systemd and restart Jenkins:
sudo systemctl daemon-reload sudo systemctl restart jenkins
Verify the status:
sudo systemctl status jenkins
Passwordless Login and Build Limits
Passwordless Login
If you forget your Jenkins password:
Edit the Jenkins configuration file:
sudo vim /var/lib/jenkins/config.xml
Set
<useSecurity>false</useSecurity>
.Restart Jenkins:
sudo systemctl restart jenkins.service
Changing Build Limits
Dashboard > Manage Jenkins > Nodes > Built-in Node > Configure.
Adjust the number of executors (e.g., set to 3).
Save the configuration.
Issue Resolution: Restoring Deleted Jobs
Dashboard > Manage Jenkins > Plugins > Available Plugins > Job Configuration History > Install.
Return to the top page.
Now, you can try to delete a job, and Jenkins will retain a history of job configurations, allowing you to restore deleted jobs.
Conclusion
Understanding Jenkins parameters, configuring port settings, and addressing common issues ensures a smooth and customized CI/CD pipeline. Jenkins' flexibility and robust features make it an invaluable tool for automating software development workflows. Keep exploring and enhancing your Jenkins setup for optimal results. Happy automating!