create consolidated build report from multiple jenkins instances - bash

I am having multiple jenkins instances like Jenkins A, Jenkins B and Jenkins C.
Now I am trying to make a report which will have the details about all of the three jenkins at one place.
report about : "Total Build", "Success", "Failed".
( from jenkins A,Jenkins B, Jenkins C)
Is there any shell script which runs on every Jenkins Instances and combine the Script Output at one place?

Make sure anonymous has read access to all your jobs in jenkins. Use powershell to invoke the job's url in the following format
http://jenkinsA:8080/view/viewname/job/jobname/1/console
http://jenkinsA:8080/view/viewname/job/jobname/2/console
http://jenkinsB:8080/view/viewname/job/jobname/1/console
http://jenkinsC:8080/view/viewname/job/jobname/2/console
Keep a count for the number of possible builds for each job. Each time your count is incremented, create an http request in powershell to invoke the url. If the request returns 404, you know the build does not exist and if it is http 200, the build exists. extract the line 'Finished:' which will give you either success or failure.
Based on the results, increment your success or failure count.
Hope it helps!

Related

Pausing Teamcity builds that are running

I would like to have Teamcity build configuration that currently has 3 build steps:
Build an artifact to perform tests on & install on remote server
Kick off long running test job on remote server
Pause build awaiting external event (i.e. remote job finishing)
Retrieve results and record the report
I have had a look through the documentation and I can see how I can pause (step 3) the entire build configuration (which stops any additional builds running) ... but not just a single running build.
The Step 2 script that is running the external job has the various parameters passed to it, so that it can issue a REST call back to the teamcity server to resume the build job.
Basically I don't want to tie up a build agent waiting the entire hour the test takes to run.
I have googled and everything I can find points me at pausing the build configuration.
I am currently having to look at splitting the build configuration into two. The first will kick of the test job and finish. Then when the external test job finishes it will call teamcity to start a second job to retrieve and store the reports. But that feels disconnected to me in that I will not be able to show a single job with build/test/report.
At the moment (TeamCity v 2018.1) there is no direct way to pause the build, release the build agent, and later resume the execution.
What you described is the recommended workaround.
Also, please watch/vote for related issue: https://youtrack.jetbrains.com/issue/TW-30777

Run Jenkins Job Based on Another Job's Status

I have a number of different projects, with Jenkins CI jobs configured for each of them to run tests. When I create a new release, I have a second job that coordinates between a number of different jobs that go over each of the modules in the projects and updates the versions and the dependencies in the pom.xml's. I would like to make the "update" job conditional on the status of all the CI jobs - meaning that if one of the CI jobs is not green, then the update job will not run at all.
I had a look at the Run Condition Plugin as well as the Conditional BuildStep Plugin, however it does not seem possible do configure them to be dependent on the status of another Jenkins job.
you could hit the other jobs via the API at [JOB_URL]/lastCompletedBuild/api/json and verify the result for each.
to mess around with this:
curl `[JOB_URL]/lastCompletedBuild/api/json` | jq '.result'
you probably want result to say SUCCESS.
this is not fancy, but you don't want fancy in CI; you want something that is not likely to break when you upgrade jenkins. :)
Have a [https://wiki.jenkins.io/display/JENKINS/Multijob+Plugin] ["Multijob Plugin"] ,
In your case, you can add a job in first step and configure in that step, at which result condition of first step, you want to run second step.
Again, in second step, you can configure one/many jobs and can also configure if you want to run them in parallel.

How to aggregate build status of multie Jenkins jobs that run HP performance centre script

I have almost 50 freestyle Jenkins builds that run as many performance centre tests everyday morning and evening. Currently I am getting status of these individual runs on email but would like to consolidate the results in one e-mail. Now problem with this is output of Jenkins build is always pass when it is able to run pc tests. To find actual result I need to see the artifact that contains HTML result. Is there a way I can read these individual HTML output and group them in one report. Like
Dev test prod
Test1 pass fails pass
Test2 fail pass pass
Test3 pass pass pass
I have little programming or scripting exp so pls forgive me for not using much resources on my own
You may use build result trigger plugin to monitor as many jobs required. For consolidating use tutorial HTML Agility Pack

Dynamically identify a Jenkins build

Currently, I am initiating a build by posting a few parameters to Jenkins from a shell script. I need to check whether the build succeeded or failed and I was wanting to avoid using the post build Jenkins script calls (I don't want Jenkins to initiate the running of any scripts on my server), so the idea was to post to Jenkins every 10 seconds or so (while building != false) in order to get the JSON object with the various build parameters. While this is working fine if I know the build number of the build I want to check on, I can't seem to see a good way to dynamically keep track of the current build number and make sure my script is checking on the build it just initiated and not some other build currently running.
Potentially, there could be multiple builds initiated within a short period of time, so posting to jenkins/job/my_build_job/lastBuild/api/json just after starting the build and checking the number that way doesn't seem appropriate given problems with race situations.
How can I keep track of a particular build dynamically from a script on my server in order to check the build success or failure of a build initiated from a post called by cron? Is there perhaps a way to name a build so I could initiate it with BUILD_NAME and then post to jenkins/job/my_build_job/BUILD_NAME/api/json?
There are a couple of different API calls you can make:
jenkins/job/my_build_job/api/json?tree=lastBuild[number]
will give you either the last completed build or the current build in progress
jenkins/job/my_build_job/api/json?tree=nextBuildNumber
will give you the next build number - this includes builds that are queued up waiting for resources.
There is already an issue filed in Jenkins to return the build number in the Jenkins remote API call: https://issues.jenkins-ci.org/browse/JENKINS-12827. Please add comments there so it can be worked on as soon as possible.

Downstream job to use the same build number and subversion revision as the upstream job in Hudson

I have seen some duplicate questions but the answers didn't seem to help. The following is what I need: I have the upstream Job A and its downstream Job B. I use parameterized trigger plugin to kick off Job B once Job A finishes successfully.
I want the kicked off Job B to have the same build number and use the same SVN revision which Job A used to simplify things (Both jobs use separate workspaces BTW.)
Under Job A, I checked the "Trigger parameterized build on other projects" and added the subversion revision and current build parameters to the parameters for Job B when stable.
Under Job B, I checked the "This build is parameterized" and used SVN_REVISION as a string parameter with default HEAD; and BUILD_NUMBER as a run parameter of Job A. Under SCM, for SVN url, I entered: http:// svn-path-here/trunk#$SVN_REVISION
Doing this always pulls the HEAD and uses different build number. Any help is appreciated. Thanks.
A quick web search reveals:
With the parametrized build trigger, you need to use a "peg revision" in the SVN URL. E.g. .../repository/trunk#${SVN_REVISION}
Or you can use Tracking SVN plugin.
See this thread.

Resources