Jenkins is an open-source automation server that enables developers to build, test, and deploy software applications more efficiently. It is a self-contained, Java-based program that can be deployed on-premises or in the cloud.
Common Use Cases:
- Automating build and deployment processes for web applications
- Integrating with version control systems like Git and SVN
- Implementing continuous testing and feedback loops
Jenkins Logs via Jenkins Web Interface
Logs are available at this URL:
http://<your-jenkins-url:8080>/log
Jenkins Log Files
Linux (rpm and deb)
By default logs can be viewed by running:
journalctl -u jenkins.service
To customize the log location, run:
systemctl edit jenkins
and add the following:
[Service]
Environment="JENKINS_LOG=%L/jenkins/jenkins.log"
Windows (msi)
By default, logs should be at %JENKINS_HOME%/jenkins.out and %JENKINS_HOME%/jenkins.err, unless customized in %JENKINS_HOME%/jenkins.xml.
macOS
Log files should be at /var/log/jenkins/jenkins.log, unless customized in org.jenkins-ci.plist.
War file
When Jenkins is started from a command line with java -jar jenkins.war, the log file will be written to the JENKINS_HOME directory. If no value is assigned to the JENKINS_HOME environment variable, the log file will be written to the .jenkins/log directory.
Docker
If you run Jenkins inside Docker as a detached container, you can use the following command to view the Jenkins logs:
docker logs <containerId>
Some useful commands:
1) Check status of the service:
service jenkins status
OR
systemctl status jenkins
2) Restart the service:
service jenkins restart
OR
systemctl restart jenkins
3) Various ways to check journal entries
Show all journal entries:
journalctl -u jenkins --all
Show the last 100 lines:
journalctl -u jenkins -n 100
Show journal entries since last boot:
journalctl -u jenkins -b
Show journal entries for a specific time period:
journalctl -u jenkins --since=yesterday
journalctl -u jenkins --since=1hour ago
Check File System Permissions
Verify that the Jenkins user has the necessary permissions to read and write files in the Jenkins home directory.
On Linux:
sudo chown -R jenkins:jenkins /var/lib/jenkins
How to solve the error:
“Jenkins.service: start operation timed out. Terminating”
Try increasing the systemd timeout to give Jenkins more time to start:
sudo systemctl edit jenkins.service
Add the following lines:
[Service]
TimeoutStartSec=300
How to retrieve deleted Jenkins job
You should have this plugin installed beforehand: JobConfigHistory Plugin
Then go to this URL to reactivate your deleted Jenkins job:
http://<your_jenkins_url>/jobConfigHistory/?filter=deleted
Useful links: