Jenkins : How to create a view based on multiple jobs results? - jenkins

I have multiple jobs running on Jenkins, with some outputs/graphs to measures code quality (warning, unit test result, indicator plots).
How can I create a view that summarize all these informations on one page ?

You can write a script that uses the Jenkins Remote Access API to query the status of various jobs and print a summary.
Then, you can run this script itself as Jenkins job. The summary will appear in the build log of the job.

Another way to do this is to use the dashboard view
The following are fully integrated :
joblist
warning
cppunit test result (each job should publish its result as a post-build action)
cppcheck result (each job should publish its result as a post-build action)
plot display (using the image portlet)
It still dont know how to display Doxygen link...

Related

Can you improve the Jenkins build history search bar?

We utilize our Jenkins environment to run various tests and jobs daily. Recently we have noticed some instability in our environment - I want to document our passed/failed tests cases that are outputted in the console output. I want to search thru the console output to pull specific tests or script names and have the jobs associated with those tests show up.
Using the Jenkins build history search tool, I'm only able to search thru the job title (name), property & value page (page you see after go into that job). My question: can you search through the console output via the jenkins build history tool?
Thanks in advance

How can I have different configuration for the job and one of it's run

I configured a job on Jenkins which trigger some script in python and does some tests. In the end, it gives results inside an artifact folder (so we can keep X amount of results at any time), which I am showing presenting with a Publish rich text message post-build action. Here is the pretty straight forward code:
<br/>
<h2>Results:</h2>
<iframe src=./artifact/artifacts/results.html width=1100 height=1000></iframe>
This works correctly inside a job build, but if you go inside the main page of the job, I get a 404 not found since it cannot find the file. I understand that the error is correct, since it cannot find any artifact folder if we are not within a build of the said job. My question is how can I have different settings depending if we are inside the main page of the job vs a build of the job ?
I checked online and found that there is a lastSuccessfulBuild variable I can use but then I think it will show the same results no matter which build we are, which is something I do not want.

Storing Jenkins pipeline job metadata?

Is there a way where to store some metadata from Jenkins pipeline job, e.g:
We have a Jenkinsfile which builds a gradle project, creates docker image and pushes it to google cloud
Then a "Subjob" is launched which runs integration tests (IT) on that docker image. Subjob receives a couple of parameters (one of them - the generated docker image name)
Now sometimes that IT job fails, and I would like to re-run it from the main job view, so idealy:
we have a plugin which renders a custom button in blue ocean UI on the main job
By clicking that button a subjob is invoked again with the same parameters (plugin queries the jenkins api, get params of this job, and resubmits the subjob).
The problem ? How to get/set those parameters. I could not seem to find a mechanism for that, expect artifact storage. I could get away with that by creating a simple json/text file and uploading it as artifact, and then retrieving it in my plugin, but maybe there is a better way?
Stage restart is not coming to Scripted Pipelines so that does not look like ant option.
Maybe you can use the Jenkins API to get the details of the build?
https://your_jenkins_url.com/job/job_name/lastBuild/api/json?pretty=true
Instead of lastBuild you can also use the build number or one of lastStableBuild, lastSuccessfulBuild, lastFailedBuild, lastUnstableBuild, lastUnsuccessfulBuild, lastCompletedBuild
There is a parameters key there with all parameter names and values used in the build.
More details on https://your_jenkins_url.com/job/job_name/api/
Also, any reason you can't use the replay button in the IT job?

Is there a way in Jenkins to iterate over the build steps and extract the results?

I have a Jenkins job that I use to execute tests, and I would like to compile+send a nice-looking report. Each set of tests is executed by a "MultiJob Phase" step that references another job and passes in the specific parameters - there are several of these steps and more will be added in the future. I'm using the "Editable Email Notification" plugin to send my notification. So I'm wondering if there is a way to iterate over my build steps, extract step names and results of those steps, so that I can present that information in my notification? Would appreciate any help!

How do I get a list of jobs with longest build time in Jenkins

I need to generate a weekly report on our Jenkins build cluster. One of the reports is to display a list of jobs that have the longest build time.
The solution I can come up with is to parse the "Build history" page on each slave (also master) and for each build of a job, parse the build page and look for "Took x min x sec on slave-xx".
This feels quite cumbersome, does anyone know a better solution using Jenkins API or Groovy script console?
Thanks
You can get the build data for your report through the Jenkins API. For a given job, you can
retrieve the list of builds with duration information using something like:
http://jenkins:8080/job/my-job/api/json?tree=builds[id,number,duration,timestamp,builtOn]
To see a list of all the API-available build data for a given job:
http://jenkins:8080/job/my-job/api/json?tree=builds[*]
Once you have a query that retrieves the job information that you need for
your report, it should be straightforward to loop over the jobs.
Most Jenkins pages have a link at the bottom to the REST API that describes a bit about accessing the API for that page, e.g. http://jenkins:8080/job/my-job/api.
How about using plugins?
Check this out:
https://wiki.jenkins-ci.org/display/JENKINS/build-metrics-plugin
There are few others too which you can try depending on how much customization/features you want to do/display:
https://wiki.jenkins-ci.org/display/JENKINS/Global+Build+Stats+Plugin - This is quite extensive
https://wiki.jenkins-ci.org/display/JENKINS/Project+Statistics+Plugin
https://wiki.jenkins-ci.org/display/JENKINS/eXtreme+Feedback+Panel+Plugin

Resources