At the moment, in Jenkins 2.204.1, using JSON API it is not possible to retrieve date of build job. How can I add that field to build info?
On the bottom right of the build page there is an API link. There I found this URL for querying the build timestamp:
https://JENKINSROOT/job/JOBNAME/BUILDNUM/buildTimestamp
Example output: 2/28/20 10:23 PM
This could be local-dependent.
You can also specify a date format:
https://JENKINSROOT/job/JOBNAME/BUILDNUM/buildTimestamp?format=yyyy/MM/dd+HH:mm
Example output: 2020/02/28 22:23
To get latest build you can use literal "lastBuild" in place of BUILDNUM, e. g.:
https://JENKINSROOT/job/JOBNAME/lastBuild/buildTimestamp
Related
I am getting this issue on the integration of Jenkins with Xray using Jenkinsfile. Error:-
Unable to confirm Result of the upload..... Upload Failed! Status:400 Response:{"error":"Error assembling issue data: project is required"}.
Does anyone have an idea about this issue and how to resolve it?
The issue is because you are using the endpointName: '/cucumber/multipart', when using this endpoint Xray expects either:
One file with the test results in json format and a second json configuration file where you configure other values (use inputInfoSwitcher: filePath and importInfo: <file_path>)
One file with the test results in json format and a json text with the extra configurations you want to pass to Xray ((use inputInfoSwitcher: fileContent and importInfo: <json_text>)
Notice that if the values of the configuration file or the json text are not correct they will not be used.
In the above case it seems that you are not correctly replacing the values in the json text.
You can find more info here: https://docs.getxray.app/display/XRAY/Integration+with+Jenkins#IntegrationwithJenkins-Pipelineprojectssupport
I am creating a Oracle Report. The report is supposed to take a bunch of input and create the report. It is not working for some specific cases.
The input are as follows
1. Account number
2.org id
3. start _date
4.end date
the report is supposed to generate a report for the org_id(constant) based on the account number and for date between start date and end date.
When the account_number is not provided it will return all the information regarding all accounts.
It works when I give specific account information
It works for specific dates (10-jan-25th jan ,20thjan-31st-jan) with out any account number: i.e. it returns information about all account number for given time period.
but it fails to give me information about 10-jan-31st jan. Which I can not figure out why.
I have tried to get the xml and put it in the template and create a preview,
the preview does not work and gives me the following error:
error: Conf File: C:\Template Builder for Word\config\xdo config.xml Font Dir: C:\Template Builder for Word\fonts Run XDO Start Template: C:\MyFiles\XML_Publisher\lATEST OUTPUT\XXONT_M193_CANCELLED_HOLDS .rtf RTFProcessor setLocale: en-us FOProcessor setData: C:\MyFiles\XML_Publisher\Test\errchk15jan7feb.xml FOProcessor setLocale: en-us
With the longer date range, the XML file might be too big for the output postprocessor. Did you check the size of the XML file?
If this is the problem, you can use our company's Blitz Report, which doesn't have size limitations: https://www.enginatics.com/faq/#how-does-blitz-report-compare-with-oracle-bi-publisher
Using the XML API, how can I construct the query string parameters to get the Last Successful Build time and Last Failed Build time for all jobs?
I have "/api/xml?tree=jobs[name,color]" but need these 2 additional field so I can get an overall status of all jobs on the server.
you can get it by calling Jenkins server with path:
/job/[job name]/lastSuccessfulBuild/
/job/[job name]/lastFailedBuild/
For data mining reasons, I want to get build numbers range of a jenkins job that were built on a particular day. Is there a plugin that accomplishes this or any other possible way?
Thanks,
Nick
The built-in REST JSON API will give you a list of the builds for a particular job: http://jenkins:8080/job/JOB_NAME/api/json?tree=builds[fullDisplayName,id,number,timestamp]&pretty=true
Produces something like:
{
"builds" : [
{
"fullDisplayName" : "JOB_NAME #113",
"id" : "2014-10-31_23-05-20",
"number" : 113,
"timestamp" : 1414821920808
},
{
"fullDisplayName" : "JOB_NAME #112",
"id" : "2014-10-31_17-26-39",
"number" : 112,
"timestamp" : 1414801599000
},
....
If your build ids are the basic date-stamp (as above), you can do a little string processing to filter the results. Otherwise, you can convert the timestamp to the appropriate date and filter on that.
Most Jenkins pages have a REST API link at the bottom that provides more documentation, though you often need to experiment with the API to figure out what details it can provide.
Update: As #Nick discovered, the builds result is limited to the latest 100 elements by default. According to this Jenkins issue, you can use the hidden allBuilds element to retrieve "all builds". So if you need all builds, use: http://jenkins:8080/job/JOB_NAME/api/json?tree=allBuilds[fullDisplayName,id,number,timestamp]&pretty=true
Jenkins 1.568 also introduced pagination in the API results, so it's possible to retrieve results by range. The Jenkins REST API link describes the syntax if your Jenkins version supports it.
There is the Global Stats Plugin
Which also has a JSON REST API
So, I try to use plugin https://wiki.jenkins-ci.org/display/JENKINS/URLTrigger+Plugin.
I want to trigger my Jenkins job when the text "Last build (#40), 17 hr ago" in the response of provided URL is changed (build number will be different after each build).
So I made following configurations:
1. Build trigger: Set [URLTrigger] - Poll with a URL.
2. Specified URL to another Jenkins: http://mydomain:8080/job/MasterJobDoNothing/
3. Set Inspect URL content option
4. Set Monitor the contents of a TEXT response
5. Set following regular expression: ^Last build[.]*
6. Set Schedule every minute: * * * * *
7. Trigger the job on another Jenkins
Actual result: My job wasn't triggered.
Then I tried to deal with XML/XPath and specify
8. Set Monitor the contents of an XML response
9. Set XPath: //*[#id="side-panel"] (also tried with one "/")
Actual result: the same.
Tell me please what I'm doing wrong? Please provide examples of RegEx or XPath if possible.
Thanks, Dima
I managed to trigger reliably with regex setting.
The regex pattern matches each line of the input.
No need to use ^ or $. it always match line start to line end.
This plugin compares the contents of the matched lines. It triggers if different.
This plugin compares the count of the matched lines. It triggers if the count is different.
This plugin uses matches() method of java.util.regex.Matcher. So the regex pattern should conform to it. (it's fairly normal regex)
As for your example,
Last build.*
may work.
Refs:
Reference of regex patten:
http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
Reference of Matcher: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html#matches()
The regex trigger source code:
github.com/jenkinsci/urltrigger-plugin/blame/master/src/main/java/org/jenkinsci/plugins/urltrigger/content/TEXTContentType.java
I'd recommend to use the "RSS for all" link as a trigger URL instead, and /feed/entry[1] as the XPath expression for the XML response content nature.
PS: I was using PathEnq to debug the XPath expression.