Jenkins MultiJob Plugin does not aggregate downstream test results - jenkins

I am using the jenkins multijob plugin to execute a number of parallel builds in the same build phase and i want to display the test results in the main multijob project so i select a post-build action step to 'Aggregate down stream test results' and select both options 'Automatically aggregate all downstream tests' and 'Include failed builds in results' but when the jobs complete and i go into the main multijob project it shows 'no tests' under 'Latest Test Result' link...
Has anyone else encountered this issue? My downstream 'child' projects that run in parallel are multi-configuration projects.

As a previous poster indicated, this is an open issue in the Jenkins JIRA and does not work. There is a workaround to achieve what your looking for. Your going to need the Copy Artifact Plugin and to also Archive the test result files as Artifacts in your jobs that are doing the test runs.
After you have installed this and configured your test run jobs properly, go to your Multijob and after all your test phases add a build step "Copy artifacts from another project" for each of the jobs you want the test results from. You can use "Specified by permalink" and use the "Last build" permalink to always retrieve the latest artifacts. Select the artifacts you want to copy (i.e. *.xml), and input your target directory as something like "job1". If you add multiple build steps to copy artifacts from another project, just name your target directories for the copied artifacts something similar like "job2", "job3", etc.
Then select a Post-build action in your Multijob as you would to Publish JUnit test result report (or whatever you prefer) and input **/job*/*.xml (or similar).
This is what I did, and it works just fine. It is a bit manual in the setup, but it works great once its configured.

Related

Subsequent build job in Jenkins does not find workspace file

I have separated my build tasks in several jobs. The following is a simplified structure.
The basic jobs are:
compile
quick-tests
full-tests-part-1
full-tests-part-2
Additional jobs are:
full-tests
full-build
Each job is configured to accept a workspace parameter to allow all jobs to be executed on the same code (workspace). This is passed from any calling job. Besides, all jobs are running on a slave node.
Job full-tests is configured to bundle the "full tests". Therefore it uses the build step Trigger/call builds on other projects with projects full-tests-part-1, full-tests-part-2.
Job full-build is configured to bundle the build pipeline. Therefore it uses the build step Trigger/call builds on other projects with projects compile, full-tests.
Job compile checks out the Git repository and compiles the code. Afterwards it starts the quick tests. Therfore it uses the post build action Trigger parametrized build on other projects with project quick-tests.
All compilation and test runs are triggered by Ant scripts.
When I trigger the full-build job, the following job sequence results:
full-build
compile (triggers quick-tests)
full-tests
full-tests-part-1
full-tests-part-2
quick-tests
The problem is, that the "full tests" are failing, whereas compile and quick-tests succeed. Both, the full and the quick tests, use the same build.xml in the same workspace, but the "full tests" complains.
Quick tests:
Buildfile: J:\jenkins-slave\workspace\full-build\272\project-path\build.xml
Full tests:
ERROR: Unable to find build script at J:\jenkins-slave\workspace\full-build\272\project-path\build.xml
Does anyone know whether there is a difference in "seeing" the workspace files depending on whether the job is part of the build (triggered as build step) or not (triggered as post build action).
If anything is unclear, please let me know.

how to configure job in jekins if first project is build successful then trigger another project and so on with "Multi-configuration project" job

I want to trigger project in jekins if first project is build successful then trigger another project and so on.. how can do it. I hava project1 , project2, and project3, project4, project5 so on. here I am configuring "Multi-configuration project" job.
for exp:- project1->success then trigger project2->success then trigger project3
if any stage failed then doesn't trigger other project.This is "Multi-configuration project" job, because this single job, I am trigger on multiple slaves remotely.
A simple way to do this would be to define this build pipeline using the Pipeline plugin.
This pipeline script should give you the desired behaviour:
build job: 'project1'
build job: 'project2'
build job: 'project3'
build job: 'project4'
build job: 'project5'
i.e. A build of each job will be started in sequence; if any one of them fails, then the subsequent jobs will not be started.
Even with "Multi-configuration project" you should be able to set a post-build action "Trigger parameterized build on other projects". Then you can specify condition which will define when this project should be build, and add parameters, including "build on the same node".

Triggering the same jenkins job after the build is finished in Jenkins

Is there a way to trigger the same job when the build is finished. I have one job that needed to be run until I aborted it manually. Is there a way to accomplish this?
The easiest way to do this is to add a post build step that builds the same project. Set "Post-build Actions" - "Build other projects" - "Projects to build" to the name of your project and it will loop forever.
This is a pretty crazy request. Are you sure that's what you want to do? If you just want to keep up to date you could just have the job build when the SCM system changes- even down to using the filesystem as an SCM.
If you really want to do it though, it is possible. You can't just tell it to trigger itself, but you can use the REST api.
Add a shell build step with the line
curl -X POST http://localhost:8080/job/Tester/build
and a new job will get scheduled each time you run build.
There is "Build after other projects are built" under "Build Triggers" in job configuration page in which you can specify which project to build after which project. So if you want to continuously run a particular job, you can add Project name i.e your job name in "Projects to watch" field under "Build after other projects are built" and can run it with options :- Trigger only if build is stable
Trigger even if the build is unstable
Trigger even if the build fails
you can try
add build step to create few files - file per condition set
add build step Trigger/call builds on other projects with add parameter factories with For every matching file, invoke one build
the called project might have input file as a parameter - it would be passed from the parent project from #2.

Copying artifacts from multiple upstream jobs at join in Jenkins

Is it possible to have a Jenkins Job with has been triggered by the Join plugin copy artifacts from multiple upstream jobs?
I'm trying to set-up a Jenkins configuration with a "diamond" of jobs: my-trigger runs and spawns two jobs, my-fork1 and my-fork2, that can run concurrently and take varying amounts of time, and the Join plugin sets off the job my-join once both forks have completed.
Each of my-trigger, my-fork1 and my-fork2 creates and fingerprints artifacts (say, text files).
I want to copy the artifacts from each of the upstream jobs in my-join using the "Copy artifacts from another project" tool, with the "Which build" parameter set to "Upstream build that triggered this job". However, I see output like this in the console of my-join:
Building remotely on build-machine in workspace /path/to/workspace/my-join
Copied 1 artifact from "my-trigger" build number 63
Copied 1 artifact from "my-fork1" build number 63
Unable to find a build for artifact copy from: my-fork2
and the job fails. In this case, my-fork2 finished first, so my-fork1 triggered the join step. I believe that that means that my-join only has record of my-fork1 and my-trigger as being upstream. If my-fork1 finishes first, then my-fork2 kicks off the join, and the job fails when trying to copy from my-fork1.
If I change the configuration to copy the artifact from the build "Latest successful build" then the build succeeds, but my-trigger may run many times in succession so there would be no guarantee that my-join is joining related artifacts.
How can I get the join step to copy artifacts from multiple forks upstream?
Note: the second point of this question seems to be asking the same thing, but the only answer there doesn't address it, and has been accepted.
Thanks
tensorproduct
If your builds are parameterized with a unique parameter for each run of the join-diamond, you can use that parameter in the CopyArtifact plugin to determine which build to copy from. You would want to specify "Latest successful build" and qualify it with the parameter and value.
We have a similar situation where I work; multiple simultaneous runs of a join-diamond. The parameter in the build allows the downstream jobs to get the correct artifacts from the upstream jobs.
Step by Step settings of the provided solution from Jason Swager:
Project dependencies:
diamond->fork->diamond_ready
Project "fork":
String parameter "UNIQUE_ID" (only dummy not used inside)
(Creates an artifcat and Archive the artifacts)
Project "diamond_ready"
String parameter: UNIQUE_ID
Copy artifacts from another project
Project name: fork
Parameter filters: UNIQUE_ID=${UNIQUE_ID}
Project "diamond":
Trigger parameterized build on other project
Projects to build: fork
Predefinded parameters: UNIQUE_ID=${BUILD_TAG}
Join Trigger:
Post-Join Actions:
Trigger parameterized build on other projects
Projects to build: diamond_ready
Predefined Generator parameters: UNIQUE_ID=${BUILD_TAG}

running a shell script once build passes

I have a job that is running unit tests on a project build and then ssh into a staging server and pulling down from the master branch. Right now I'm using the post-build-script but this is running regardless of pass/fail. I'm trying to use the parameterized build plugin to trigger a new job when the build is passed. So far I've created the new job and set to trigger in the configuration of the original.
The new job is building ok on its own but the original job isn't triggering it. From 'Add post-build action' I've selected 'Trigger parameterized build on other projects' with build triggers:
Projects to build: new_job, Trigger when build is: Stable or unstable but not failed.
Any ideas appreciated!
C
If you don't actually need to pass a parameter to the second build, make sure that "Trigger build without parameters" is checked in the parameterized build trigger options.
The "Post build task" allows you to query the console log of the build step, and is executed only when criteria is met.
Jenkins writes BUILD SUCCESSFUL in the console log for every build step that had passed.
In your "Post build task" step, under Log text just put BUILD SUCCESSFUL, and under Script put your linux script/commands.
This way your script/commands will only be executed if the Build Step was successful

Resources