publish junit test result report from parent's workspace - jenkins

I have a parent job and two child jobs in jenkins. The workspace shared by the child jobs resides within the parent job.
Now the child jobs are producing a Junit RspecFormatted logs (job1.xml and job2.xml), which is getting stored in the parent's job workspace.
I am trying to refer giving the full path:
$JENKINS_HOME/workspace/{parent-job}/{folder a}/{folder b}/{folder c}/test-results/job1.xml in the post build result section but the build fails to find this path.
Note: I am able to print the file in the Execute Shell section with this path

I'm not really sure about the issue, can you give me more details?
By the way if i understood your needs, you can use the:
https://wiki.jenkins.io/display/JENKINS/Parameterized+Trigger+Plugin
To get variables like TRIGGERED_JOB_NAME and NUMBER, so you can build the PATH
$JENKINS_HOME/workspace/${TRIGGERED_JOB_NAME}/{folder a}/{folder b}/{folder c}/test-results/job1.xml
What about folder a/b/c, where are these variable valued?
You can also simply pass these information as parameters and than use them as variables to dynamically build the path...
Let me know if it's clear and if it helped...

Related

Copy build history from one job to another job

I have a Jenkins job that is a declarative pipeline. It's URL is $JENKINS_URL/job/dnscheck/.
I started using Bitbucket projects on Jenkins, and now that Jenkinsfile is also discovered and the same job lives at $JENKINS_URL/job/website/job/dnscheck/job/master/
I want to copy the entire history (log files etc) from $JENKINS_URL/job/dnscheck/ to $JENKINS_URL/job/website/job/dnscheck/job/master/, and then delete $JENKINS_URL/job/dnscheck/.
Can I do that?
If yes, how do I do that?
I don't want to overwrite existing files
On the master, the logs are all stored in ${JENKINS_HOME}/jobs/<path/to/job>/builds/, unless overridden by a system property jenkins.model.Jenkins.buildsDir. They consist of a series of numbered directories with a log file (the build log) inside and possibly some additional data files (eg: build.xml, changelog.xml, injectedEnvVars.txt).
There are also some sym-links for last builds (good/bad, etc.), both inside the jobs directory and inside the builds directory. You could copy all the directories over (renumber if you have conflicts) AND update the sym-links accordingly. You may also need to reset the last build ( Number of builds since the start of the project ) to n+1 so that the next build number increments w/o overlapping. It's in a file inside /nextBuildNumber.
Finally, you must get Jenkins to recognize the new content since Jenkins caches everything. You can do that by either restarting the system, reloading the configuration from disk or less drastically, reload the data on the one job, something like:
def configXMLFile = job.getConfigFile();
def file = configXMLFile.getFile();
InputStream is = new FileInputStream(file);
job.updateByXml(new StreamSource(is));
job.save();

Jenkins issue with Trigger one build per property file

Job A uses "For every property file, invoke one build" parameter factory to call downstream job B.
Here is the file pattern I am using:
d:\temp*.properties
There are two files in that folder:
build0.properties
build1.properties
each file looks something like this:
modified=SampleApp
Job B fails because job A is not setting the parameters from above file. If I look at the parameters for a build of Job B, they are empty.
The process works when I use "Parameters from properties file" parameter type instead of a parameter factory, and specify the full path to one of the files, so I know the files are in the right format. I do not want to add a parameter for each file I have,
since I will have these files generated dynamically.I would prefer to use the parameter factory if possible.
Issue with the file permissions, when I pointed to workspace directory with the file pattern It started workign fine.

How to Pass Upstream Job Build Parameters to Downstream Jobs configured in a MultiJob Phase?

I have Upstream Job(MultiJob) which takes a String Parameter called freshORrerun, to take string value as "fresh" or "rerun" string value, which i need to pass on to downstream(standalone build) jobs to check the value is "fresh" or "rerun". Based on which, in child jobs's i will trigger complete tests run (pybot) or rerun (rebot) of failed tests.
here i have attached the screenshots how i have configured. When i print the passed string in child job it is empty.
Overall Job configuration.
Multi Job phase config and child Jobs
I have many no.of robot tests running them takes a lot of time. i need a way to run only failures of previous run, so that it gives me quick picture of how many got fixed. Could Some one please help me with this.
Click the 'Add parameters' button, select 'predefined parameters' and add: freshORrerun=${freshORrerun} to the list.
You can do it using one plugin called parameterized job trigger in which you will get options to pass parent job parameters to child job.
Note:- For this, you have to create parameters in child job also. These parameters will be overwritted.
plugin link

i want to make generic parameters in jenkins

How can I make generic parameters in jenkins that will be updated automatically for example I want to be able to create a parameter which hold today's date and it will be update automatically and not manually ?
thanks!
You might want to use EnvInject.
Setup your job and then add a build step "Inject envornment variables" from a file with an absolute path or the path relative to current job's workspace, which will contain something like:
DATE_VARIABLE="20150708"
OTHER_OPTIONAL_VARIABLE="value"
In previous execute shell step you may for example do:
echo "DATE_VARIABLE="`date +"%d%m%Y"` > env_inject.txt
After all that you don't need Parameters for a build, since you will have the needed parameter injected as an environment variable.

Dynamically grouping jenkins job results

I've had a dig around but can't find an elegant solution for what I want to do, so I hope some of you may be able to offer some suggestions. I've also asked this question on a jenkins forum, but no takers.
I want to be able to run a jenkins parent job with parameters that will feed down to triggered jobs, and then group all the job run results in a view dynamically.
The use case I'm trying to cover is: We have 10+ different jenkins jobs that run suites of tests, I want to simply manage a run of all those jobs to run against a specific code branch, on a specific test environment, and see the results (in one view) for only that run. The complication is the same Jenkin job may be run against another release or test environment and I don't want to see those results.
We already have the parent job triggering children with parameters, but I can't figure out how best to group the results.
I know I can create filters for views, but the name of jenkins jobs is static, and I want the view created at runtime, without having to build it myself. We do use the 'Set Build description' Plugin, so I could create a view that filters for a unique build descriptor, or something similar. But there doesn't seem to be a way to create views with filter programmatically.
Other considerations would be clean up. I wouldn't want a years worth of views clogging the views, so I need a way to clear out old runs too.
Any ideas to kick me off?
For groupping of reports you can just use a simple logic instead of finding a Jenkins plugin. You can place all the result files (preferably XMLs) in a common folder/ file server and at the end of execution of all the suites (jobs) you can trigger a common job which will process all the XML files and generate a common report. By this you can have " consolidated + individual reports ".
I have done it using Perf Publisher plugin which process XMLs and gives a beautiful aggregated report.
Job1 ----> Report1 ----> Move report of report folder
Job2 ----> Report2 ----> Move report of report folder
Job3 ----> Report3 ----> Move report of report folder
.
.
.
Job n ----> Report n ----> Move report of report folder
So after completion of job n, trigger Report job which will operate on "report" folder containing all the reports!
Hope it helps!
I have a partial solution:
All jobs accept a parameter called VIEW_IDENTIFIER.
Parent job is kicked off with a unique VIEW_IDENTIFIER being set, and all the child jobs have that passed into them when run.
After all jobs are run I edit a Jenkins View that has a 'Job Filter - > Parameterized Jobs Filter - > Name = VIEW_IDENTIFIER, Value = my unique ID set for the run'
This results in all jobs run with that unique ID being grouped in one single view for review.
The shame is I have to do the manual edit of the Job Filter.

Resources