8. Workspace
• Disposable file based storage for Jenkins engine
• Can be pointed by $JENKINS_HOME initialization parameters
• Major components
• init.groovy.d – scripts placed here are executed at start up
• plugins – directory to host .jpi files (formally known as .hpi files)
• hudson.model.UpdateCenter.xml – where to look for plugins / updates
• nodes – to keep metadata about slaves
• userContent – treat it as http host for user files
• jobs – for job information, consists of build directories
• logs – log of Jenkins
• secrets, users, updates …
10. Plugins POV
• https://wiki.jenkins.io/display/JENKINS/Backup+Plugin
• Manual
• Backs up full Jenkins home !!!
• Requires large storage space
• https://wiki.jenkins.io/display/JENKINS/thinBackup
• Schedule driven
• Loads of features
• Selective exclusion supported
• https://wiki.jenkins.io/display/JENKINS/JobConfigHistory+Plugin
• Track modifications made to job configuration
• Old school
11. Administer … Log Rotation
1. Discard older build record judiciously
2. Artifacts produced by builds usually takes disk space
3. Keep build metadata but discard artifacts
4. Parmalink to last successful build will always be kept intact
5. For important build use
12. Administer … Disk Usage
1. Monitor disk usage with https://wiki.jenkins.io/display/JENKINS/CloudBees+Simple+Disk+Usage+Plugin
2. Refrain using old https://wiki.jenkins.io/display/JENKINS/Disk+Usage+Plugin
3. Be aware of the fact that Maven jobs by default archives artifacts, that are produced during builds
1. Disable auto archiving
14. CLI
Usage examples
java -jar jenkins-cli.jar -s http://localhost:8080 -auth admin:d4b018ebd020677d95fe5e8c2c016911Login
List Available Commands java -jar jenkins-cli.jar -s http://localhost:8080 help
Get Help On Specific Command java -jar jenkins-cli.jar -s http://localhost:8080 help list-jobs
15. HTTP API
1. HTTP API available as part of major resource definition
1. …/resource_name/api
2. Media Type : Get response as XML / JSON
3. Filter : Filter response using XPath / Tree
4. Volume : “depth” factor controlling amount of data being received
5. Resources
1. Overall
2. Job
3. Queue
4. Build
5. Load
6. Management operations can not be done over HTTP API
16. HTTP API Invocation
• Jenkins by default has CSRF Protection enabled which prevents one-
click attacks. This mandates you using Crumb while invoking API
• From 2.0 onward
• However you will require to enable this in any earlier version
Step 1 : Get Crumb for yourself
Step 2a : Build a job
wget -q --auth-no-challenge --user admin --password admin --output-document -
'http://localhost:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST
'http://admin:89dba97bd886ee392ee3acc735378ec6@localhost:8080/job/job-1/build' -H "Jenkins-
Crumb:e5a28794c8afff48509e40d21f0e383a"
17. HTTP API Invocation
Step 2b : Build a job with parameter
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST
'http://admin:89dba97bd886ee392ee3acc735378ec6@localhost:8080/job/job-
2/buildWithParameters?YOUR_NAME=JenkinsFan' -H "Jenkins-Crumb:e5a28794c8afff48509e40d21f0e383a"
18. Useful Urls
• http://localhost:8080/about/ : get information about version & plugin
• http://localhost:8080/systemInfo : get info about properties
• http://localhost:8080/threadDump : get info about thread waiting state
19. Challenges : Jenkins@Enterprise
• Challenge : new plugin version breaks Jenkins (accidentally)
• Resolution : use sacrificial Jenkins instance
• Challenge : disk overflowing with artifacts
• Resolution : establish backup / restore policy & have sensible build retention policy
• Challenge : script spaghetti
• Resolution : have a policy to manage custom scripts
• Challenge : resource depletion
• Resolution : enable monitoring
• Challenge : general lack of consistency between jobs
• Resolution : introduce template job definition & keep variations limited