Jenkins Cheat Sheet
Jenkins Cheat Sheet
Jenkins is a software which allows you to do the continuous integration on your application/software lifecycle. It gets installed on the server where the central build will take place. Now let’s understand its workflow.
- Can be used to manage paths to various tools to use in builds.
- Jenkins dynamically adds the config fields after the plugins are installed.
- Plugins can be removed, updated and installed by manage plugin screen.
- List all the current java properties and system environment variables.
- System log- view Jenkins log in real time.
- Script console- lets you run groovy scripts on the server.
- Manage nodes- configure the number of builds you want.
- Shutdown- click prepare to shutdown link to prevent any new builds from being started. After all current builds are finished, Jenkins will shut down cleanly.
Testing unit in Jenkins:
Step 1 : Go to the dashboard and choose an existing project and click configure
Step 2 : browse to add a build step and invoke Ant
Step 3: Click on advanced
Step 4 : in the build file section enter the location of build.xml
Step 5: add post build option and click Publish Junit test result report
Step 6 : ensure the report is in the folder of the project workspace The “*.xml” basically tells Jenkins to pick up the result xml files which are produced by the running of the Junit test cases. Click Save after done.
Step 7 : Click on build and check logs to see if successful or not with applications.
Step 1: go to plugins and choose selenium plugins and click to install.
Step 2: go to configure system and select on selenium jar and save
Step 3: Go to dashboard and select the config option for the project at hand
Step 4: Click on add build step and choose SeleniumHQ htmlSuite Run”
Step 5: Add the required details and click on save, execute and build. The test is executed, and a report is built.
- Head to the manage plugins and install the respective plugins
- It takes the war ear file and deploys that to the running remote application build
- Go-to build and configure and click on ‘deploy to war/ear to container’
- In the war container section save details about the destination server and click save.
- To tweak backup settings via setup
- To backup Jenkins config
- To restore config from a previous backup.
- Alternatively you can use SCM( sync config plugin) or ThinBackup for global and job configurations.
- Jenkins comes with a feature to add email notifications to the build project
- Go-to Manage Jenkins → Configure System. In the email notification space enter the require STMP server and use email suffixes.
- Configure the recipients so that they would receive notification about broken or unstable builds
- Notification plugins such as Tikal Knowledge allows job status notification for JSON and XML formats.
- Options :
- Format – either Json or XML types
- Protocol- TCP, UDP or HTTP
- Event – job event that triggers the notification
- URL- destination to send notifications to.
- Timeout – default timeout 30ms
- To uninstall plugins , go-to manage plugins and click on the installed tab and click on uninstall for the plugin
- In Case of need to install an older version of the plugin, download from the site and click on Upload option to do it manually.
They provide utilities for static code analysis. Some tools are CheckStyle, FindBugs, PMD etc. Provides details like :
- Total warning in a job
- Showing of new and fixed warning of a build
- Trend reports showing warnings per build
- Warnings per module, package or category
- Detailed reports of found warnings.
- Ability to have secure config for different users in place.
- Click on manage Jenkins and Configure global security
- Set parameters in the enable security section
- Add the users and go-to ‘manage users’ for permissions
- To set authorizations, go-to configure global security, and click on matrix based security
Commands in Jenkins: (URLs)
- http://localhost:8080/jenkins/exit − shutdown Jenkins
- http://localhost:8080/jenkins/restart − restart Jenkins
- http://localhost:8080/jenkins/reload − to reload
To backup Jenkins Home:
- Go to configure system in manage Jenkins
- Select a partition that has to most free space.
- Perform automated clean-up options to avoid this
- First go-to manage plugin and install build pipeline plugin.
- To see a build pipeline click the (+) on the dashboard
- Enter any name and click on the view. Choose build pipeline view.
- Accept the default settings and add the name of the project.
- A view of entire pipeline with statuses will be visible.
Selenium tests can be run on remote slave machines via master slave and selenium suite plugin installation
- Step 1: go-to master Jenkins server and manage nodes
- Step 2: Click on configure for the slave machine
- Step 3 : put the launch method as ‘Launch slave agents via Java Web Start’
- Step 4: open a browser instance of the master Jenkin on the slave machine, then manage nodes and select the DXBMEM30
- Step 5 : Scroll down and select the launch option and hit run
- Step 6: Configure tests to run on the slave
- Step 7 : make sure the selenium part of the job is configured. Make sure that the Sample.html file and the selenium-server.jar\