Have Jenkins read the first column from a table in Confluence - jenkins

I have to do a server-deployment on a weekly base which i am trying to automate as much as possible. Right now i am stuck, because i get some information from my companies confluence page where a few scripts are listed ordered by version.
As i already have some automation going in jenkins i wanted to try to get jenkins to read from this confluence page and have it execute e.g. all scripts from the 3.5.2 version in a step.
Can i somehow get information out of confluence with jenkins? Right now i do this manually every time. Any help is greatly appreciated!

Create a script in jenkins
Do a wget call in your jenkins script to call the confluence REST API to get the content of your page
Use jq to parse the content that comes back from confluence.
Parse the field you want and get the scripts you want
If you're feeling happy, you can even update your confluence page and say that your jenkins job ### ran these scripts.
I have created a blog on something similar:
http://javamemento.blogspot.no/2016/05/jira-confluence-3.html
There is some code in github too, if you're interested.

Related

Get Jenkins Pipeline Build steps

I have a jenkins pipeline which I have written using Declarative pipeline syntax. The pipeline is running fine. I am able to view steps and detailed steps.
Now, the client has a requirement where they want to see these steps in a report fashion. They want to show/handover these reports to their audit firm. The thing is they don't want to give their audit firm jenkins access. The audit firm should be able to view whatever is going on in the pipeline.
So, I made the console output of the build in a pdf file. Now, they want to see the steps too.
First is the simple pipeline steps view,
Second is the detailed pipeline steps view,
Now I have to display this in another file.
Is there a plugin to export these steps in a visual format?
If not using a plugin, is there an API from which I can extract the text of these steps? I see they are not available in the /api/json endpoint of a build.
Anything else that can be done?
Thanks.
BlueOcean API has the info you need at
${YOUR_JENKINS_URL}/blue/rest/organizations/jenkins/pipelines/${JOB_NAME}/runs/${BUILD_ID}/nodes/"

How to update confluence page from jenkins job

Is anyone updating confluence page from jenkins job? How? For example we would like to generate some releasenotes on some confluence page or add some data regarding a build. There is plugin which is very old and not working with confluence ver greater than 6.
Should we use confluence cli?
The best way is to use confluence REST. Create a user (e.g. JenkinsBot) in your confluence instance and use that bot's credentials in your script for Jenkins to create a new page inside a specified space or update an existing page.
There is this repo in github for a similar thing which we used to trigger at the end of our jenkins build to release the note we supplied.

Log build file size using Jenkins and display results

This is a broad question, so any answers are deeply appreciated. I need to continually log the size of several build files (in this case some CSS and JS files), preserve this log and ideally show it as a dashboard in Jenkins.
I know that I can setup a cron job and execute a bash script to grab the files and log their size, but I'm not sure where this file would live and how to display it. Ideally the result would be a dashboard plot or bar graph over time.
Thanks.
P.S. I'm open to other logging suggestions, but Jenkins seems like the appropriate system to do this in.
Update: this isn't perfect but it works. Google Spreadsheets has a simple API for posting data, so this can work as an endpoint for any script you want to write that logs your data.
It's not a Jenkins solution, but gets the job done.
In my search leading up to this, I did come across JMeter, and the Performance Plugin for Jenkins, which were contenders for a possible solution.

Jenkins cucumber reports to show on main job's page

I run cucumber tests as part of a continuous integration for one of my products. I use the Jenkins cucumber-reports plug-in.
It all works well and is very useful!
I'd like to be able to show the reports on the main Jenkins job's page and not under an inner page in the job.
Does anyone have an idea on this?
Have you tried Dashboard View plugin? I have been using it for monthes and I used it to customize my jenkin's Homepage. It give you the ability to add any portlet into your jenkins Homepage. This is how my jenkins Homepage looks like after I started to use this Dashboard View plugin. I am not sure if it support cucumber report or not but at least you can have a try.

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