Skip to main content

Posts

Showing posts with the label Jenkins

Jenkins: Purge Job History Plugin

Download and install: https://github.com/jenkinsci/purge-job-history-plugin This plugin provides the ability to purge all the build records of a job either via a CLI command or via the UI. When this plugin is installed it adds a new action to all Jobs with builds. You can either use UI as shown here (https://github.com/jenkinsci/purge-job-history-plugin) to purge any/all of the following:  Job Pipeline MultiBranch Job (Recursive Flag is Needed) Jobs under a Folder (Recursive Flag is Needed) All Job under Jenkins Instance (Recursive Flag is Needed) Or you can do it via Command line using this command: java -jar jenkins-cli.jar -s http://localhost:8080/jenkins purge-job-history <JobName> -r JobName : Name of the Job whose history you would like to purge r : To reset the next build number to 1 Note* you need super access to perform it.

How to discard Jenkins old builds from project or Pipeline?

When we work with Jenkins, we surely run our project(s) multiple times and this will result in a long queue of the build History list that mostly is of no use after certain numbers. How to discard Jenkins old builds from project or Pipeline? 1) If you have access to the " Manage Jenkins " section of your Jenkins then you can run the below-mentioned script to clean your project Build History. Note* This will reset the build number to 1 on your next run. a) Access your Jenkins HP > Manage Jenkins > Script Console b) Copy-Paste this script to your Console Script text area and update the " myproject_name " with your project name where you need to clean the build history and hit the " Run button ". def yourJobName = "myproject_name" def job = Jenkins.instance.getItem(yourJobName) job.getBuilds().each { it.delete() } job.nextBuildNumber = 1 job.save() This should clean your Build History for that particular project but if you&

Jenkins: set of commands to safely stop/restart it

Not sure about you guys but I used to stop/restart Jenkins using cmd prompt only but it looks like we have an optimized way to stop/restart i.e. through the Jenkins instance itself. Jenkins provides a set of commands to safely stop/restart Jenkins by putting it in a quiet mode. 1) quietDown: Put Jenkins in a Quiet mode, in preparation for a restart. In that mode, Jenkins doesn’t start any build 2) cancelQuietDown: Cancel the effect of the “quiet-down” command. 3) safeRestart: Put Jenkins into the quiet mode, wait for existing builds to be completed, and then restart Jenkins. 4) safeExit: Put Jenkins into the quiet mode, wait for existing builds to be completed, and then shut down Jenkins. Just hit these URLs on the browser where your jenkins is running by replacing "<jenkins.server>" with your Jenkins domain URL. http://<jenkins.server>/restart http://<jenkins.server>/safeRestart http://<jenkins.server>/exit http://<jenkins.server>/

HTML Publisher Plugin not processing CSS for online Extent Report, Gatling, OWASP, etc. in Jenkins?

Reason:  It is because of the 'Content-Security-Policy' which is introduced in Jenkins from Jenkins 1.641 / Jenkins 1.625.3, which is blocking the inline CSS.  Read here for more details: https://wiki.jenkins.io/display/JENKINS/Configuring+Content+Security+Policy Simplest solution:  Relaxing The Rules: Either use 'java -Dhudson.model.DirectoryBrowserSupport.CSP="" -jar jenkins.war' command to start Jenkins server from the command prompt or set this system property temporarily via the Jenkins Script Console: System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "sandbox; default-src 'self';") #jenkins   #reporting   #extent   #tips   #automationtesting    #testing   #seleniumautomation