Re: Jenkins dashboard report with customization
Hi Trupti Bhatt, Was damn busy , not able to respond for you mail. Please add import statement on top of your script , it must work, *import jenkins.model.** Jenkins.instance.getAllItems(Job.class).each{ println it.name + " - " + it.class def jobBuilds=it.getBuilds() //for each of such jobs we can get all the builds (or you can limit the number at your convenience) jobBuilds.each { build -> def runningSince = groovy.time.TimeCategory.minus( new Date(), build.getTime() ) def currentStatus = build.buildStatusSummary.message def cause = build.getCauses()[0] println "Build: ${build} | Since: ${runningSince} | Status: ${currentStatus} | Cause: ${cause}" // You can get all the information available for build parameters. def parameters = build.getAction(ParametersAction)?.parameters parameters.each { println "Type: ${it.class} Name: ${it.name}, Value: ${it.dump()}" } } } Other Important links that will help you are: Here is my Script Collection: https://github.com/rajendrapenumalli/jenkins-scripts Other Useful links: https://jenkins.io/doc/book/managing/script-approval/ https://pghalliday.com/jenkins/groovy/sonar/chef/configuration/management/2014/09/21/some-useful-jenkins-groovy-scripts.html dont forget to send me you solution (after removing any sensitive data ;)) *Thanks and Regards,* *Rajendra Prasad Reddy PenumalliSr. Engineer in Testing.Mobile:9008566233* On Mon, 12 Nov 2018 at 03:46, trupti bhatt wrote: > Thanks Rajendra. > > I have tried following code: but throwing me compilation error: > > Jenkins.instance.getAllItems(Job.class).each{ >> println it.name + " - " + it.class >> >> def jobBuilds=it.getBuilds() >> //for each of such jobs we can get all the builds (or you can limit the >> number at your convenience) >> jobBuilds.each { build -> >> def runningSince = groovy.time.TimeCategory.minus( new Date(), >> build.getTime() ) >> def currentStatus = build.buildStatusSummary.message >> def cause = build.getCauses()[0] >> >> println "Build: ${build} | Since: ${runningSince} | Status: >> ${currentStatus} | Cause: ${cause}" >> // You can get all the information available for build parameters. >> def parameters = build.getAction(ParametersAction)?.parameters >> parameters.each { >> println "Type: ${it.class} Name: ${it.name}, Value: >> ${it.dump()}" >> } >> } >> } > > > > Error Is : > >> ERROR: Build step failed with exception >> groovy.lang.MissingPropertyException: No such property: Jenkins for >> class: Script1 >> at >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) >> at >> org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52) >> at >> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307) >> at Script1.run(Script1.groovy:1) >> at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585) >> at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623) >> at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594) >> at >> org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:343) >> at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:95) >> at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:59) >> at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) >> at >> hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744) >> at hudson.model.Build$BuildExecution.build(Build.java:206) >> at hudson.model.Build$BuildExecution.doRun(Build.java:163) >> at >> hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504) >> at hudson.model.Run.execute(Run.java:1815) >> at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) >> at hudson.model.ResourceController.execute(ResourceController.java:97) >> at hudson.model.Executor.run(Executor.java:429) >> Build step 'Execute system Groovy script' marked build as failure > > > On Thursday, November 8, 2018 at 3:49:14 PM UTC+5:30, rajendraprasad reddy > wrote: >> >> Hi Tripti, >> You are correct there is no plugin that can help you to create a custom >> dashboard specified by you. >> >> All you need to write a groovy script to access Jenkins job history and >> prepare report according to your need >> >> >> First get list of jobs via groovy script: >> >> Jenkins.instance.getAllItems(Job.class).each{ >> println it.name + " - " + it.class >> } >> >> >> Next get each job and get build status : >> Following link has script that can help you in that: >> >> >> https://github.com/cloudbees/jenkins-scripts/blob/master/get-build-information.groovy >> >> You need to use groovy plugin and it looks like below link. >> >> >> https://www.google.com/search?safe=active=jenkins+groovy+script+examples=X=2ahUKEwj-weOYx8TeAhXEtI8KHbCMABQQ1QIoA3oECAoQBA=412=660=2.63#imgrc=qnNClrZNVTUKnM >> : >> >> I know I didn't have you full
Re: How to SET BUILD_USER variable from REMOTE API CALL to Jenkins Job
I don't think Jenkins has BUILD_USER var. If you're using a plugin to generate it, you may want to check there. On Friday, November 16, 2018 at 2:57:24 AM UTC-8, rohit verma wrote: > > Hello, > > I am calling a Jenkins Job from remote system by following command. > > curl -k -v -H -XPOST > "https://:@JenkinsURL/job/JobName/buildWithParameters?token=TokenName=PRM_VALUE" > > > What i noticed that the environment variable BUILD_USER is not set via > remote API call. (In my case BUILD_USER is null however the user is > triggering it with his/her authentication token). Is there a way to make > sure that BUILD_USER is set to the the user name of the caller of this job > via REST Like API (Curl command)? > > > Thanks in advance. > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/8c9e36db-0c71-48ba-87e9-bdc76f12dfc2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
BlueOcean displaying artifacts (cppcheck, coverage, etc)
Hello, I'm using a Declarative Pipeline with BlueOcean, and I'm unclear how to get BlueOcean to display artifacts from my build nicely. For instance, I used to (and still do) display a roll-up of cppcheck results in Jenkins. I also track code coverage using gcov/lcov and the standard coverage plugins, which lets me do nice things like browse the code and visualize what is covered and what is not. In the new BlueOcean view of the build system, where do these third party plugin views exist? How do I get to them? For instance, for cppcheck results I have in my post {} section: //This still produces traditional cppcheck output in the "regular" view step([$class: 'CppcheckPublisher', pattern: 'cppcheck-result.xml']) //This seems to do nothing? publishCppcheck pattern: cppcheck-result.xml More broadly, how does BlueOcean envision displaying these types of results, which used to live in the plugin's displays on the Jenkins build results area? -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAJGGFMYY9DOkuHLdXN6T9_wwDPUOcvP9dt0cPENXLeeLReQQ0w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
How to SET BUILD_USER variable from REMOTE API CALL to Jenkins Job
Hello, I am calling a Jenkins Job from remote system by following command. curl -k -v -H -XPOST "https://:@JenkinsURL/job/JobName/buildWithParameters?token=TokenName=PRM_VALUE" What i noticed that the environment variable BUILD_USER is not set via remote API call. (In my case BUILD_USER is null however the user is triggering it with his/her authentication token). Is there a way to make sure that BUILD_USER is set to the the user name of the caller of this job via REST Like API (Curl command)? Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b3a8235e-dd7f-49c3-ae61-ba6360a70b55%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Disable standard output from Jenkins pipeline:
In fact, from Jenkins doc: returnStdout If checked, standard output from the task is returned as the step value as a String, rather than being printed to the build log. (Standard error, if any, will still be printed to the log.) You will often want to call .trim() on the result to strip off a trailing newline. On Sunday, February 19, 2017 at 6:25:51 PM UTC+1, David Karr wrote: > > On Thu, Feb 16, 2017 at 8:23 AM, Geethalakshmi Ramachandran > > wrote: > > A jenkins pipeline calls an API that returns metrics and prints it in > the console output with formatting. However, Jenkins pipeline prints > standard output for each command like below: How to disable this or turn it > off? > > If you want to control how or whether stdout is emitted from a "sh" > step, instead of calling it like this: > -- > sh "command line" > - > > Do: > > sh returnStdout: true; script: "command line" > > > I suppose you could set that to "false" also,but I've never done that. > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a70604ff-d115-42cd-a953-bdd164e1a5d3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.