Read archived file from a Jenkins last successful build remotely - jenkins

In Jenkins job i am archiving xml report files.
I want to read the archived xml report files form the last successful build using python program. Is there any way to perform this.
I can reach to those file using below public VIEW URL (not API URL) but can not read them as files have dynamic name (appended date & time). Do we have any API which can return me this xml data.
http://MY-URL/jenkins/job/Services/job/{JOB-NAME}/job/{BRANCH-NAME}/lastSuccessfulBuild/artifact/newman/newman-run-report.xml

Related

Display a file path as hyperlink from archive after jenkins build

I have a pipeline job in Jenkins. Once it finishes , it archives some files. I need to display a particular file from the archived folder.
Example file is D:/1234/errorLog.txt
If job is failed , this path should be provided in the email. How can I achieve this ?
It should be able to access that folder from email, by clicking that link.
All files that are archived can be accessed via the Jenkins URL. So, for example if I had an archived errorLog.txt, I would be able to access it like this:
JENKINS_URL/job/JOB_NAME/BUILD_NUMBER/artifact/path/to/file/errorLog.txt
So if you were sending an email, the email would have to contain the formatted string with the Jenkins URL, Job name, and build number set.
You can also do this with folders. If you were to go to the artifacts root folder:
JENKINS_URL/job/JOB_NAME/BUILD_NUMBER/artifact
You would see the archived folders listed out:
So anyone clicking on the list would have the page open up in their browser.

Avoid reading the same file multiple times using Telegraf and file input plugin

I need to read csv files inside a folder. New csv files are generated every time a user submits a form. I'm using the "file" input plugin to read the data and send it to Influxdb. These steps are working fine.
The problem is that the same file is read multiple times every data collection interval. I was thinking of a solution where I could move the file that was read to a different folder, but I couldn't do that with Telegraf's "exec" output plug.
ps: I can't change the way csv files are generated.
Any ideas on how to avoid reading the same csv file multiple times?
As you discovered file input plugin is used to read entire files at each collection interval.
My suggestion is for you to instead use the directory monitor input plugin. This will read files in a directory, monitor the directory for new files, and parse the ones that have not already been picked up yet. There are some configuration settings in that plugin that make it easier to time when new files are read as well.
Another option is to use the tail input plugin which will tail a file and only read new updates to that file as things come. However, I think the directory monitor is more likely something you are after for your scenario.
Thanks!

Jenkins report publisher with json

Any idea about Jenkins extension for json result publisher? I'm using cypress to generate result which is generating result logs in .json format, I'm not sure about json report publisher nor got any concrete document. If someone knows it let me know.
I'm using Junit currently.
I believe that as of now there is no plugin that could help you to directly publish the JSON file content. But there is a workaround. once the JSON report is created, read the required data it using any suitable programming language like python or java and then display those data in the newly created html file. There is a plugin call html publisher plugin and with the help of that plugin, you will be able to display that html file.

Problem with Jenkins HTML Publisher Plugin and relative pathes in HTML report file

I'm using the Jenkins HTML Publisher Plugin for publishing HTML test reports to the job and build. The test reports and error screenshots I add after every build to the artifacts. And later I use the HTML Publisher Plugin to link to the report HTML file in the artifacts.
The test reports contain the error screenshots with relative pathes src="./../errorShots/ERROR_screenshot_2019-06-04_02:19:29:529.png". And it is running when I open the report HTML file directly under the artifacts in the specific jenkins builds. Then the images are correctly visible.
But when I'm using the HTML Publisher Plugin to link to exactly this test report HTML file the relative pathes are not working. So, the links to the embedded images are not working anymore and the images are not visible, because the relative link path seems to be wrong.
So, how can I solve the problem? I think the plugins does not create only a link to the target HTML file. If it would do that it should running with relative pathes in HTML report file.

Web API Folder to place template Reports (rpt, xml, etc.)

I have my Web API project, and one its controllers will generate Reports on the fly (PDF, Excel, etc.)
In order to generate the Reports, I have the template files rpt (crystal reports), xml (componentone), etc. My question is where is the recommended folder to place those files.
Note. The generated report won't be saved on server, the controller will just response the stream to the client.
I would put them into "~/Content/Reports" and read from there.

Resources