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

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".

Related

Creating Jobs for Multijob Plugin in Jenkins

I had a requirement for executing jobs in parallel and came across this plugin called MultiJob plugin for Jenkins.
After going through documentation, i created phases and gave job names. But where do i create job basically.I mean the script ,build step and post build step for job "TaskToExecute1" and "TasktoExecute2".
Thanks,
VVP
You need to create the jobs that are referenced from the "Job Name".
So in your example, create a separate job/project (e.g. "New Item" -> "Freestyle Project") and call it TaskToExecute1. Then you can add a build step to that new TaskToExecute job/project.

how to pass job name in plugin "trigger parameterized build on other projects" in jenkins

in this plugin , it require "Projects to build", it says
"A comma separated list of projects to build"
I set a parameter in my job configuration , let's say it's named A
A="job1,job2,job3"
in "Projects to build", I pass A
Projects to build : ${A}
but it not work, so how to do?
I have a solution using a build step (and not a post-build step) with the trigger parameterized plugin.
Add a parameter to define the child job:
Add a "Trigger/build on other projects" build step:
Trigger your job with the child job to launch:
It works:
I did a test with a list of two jobs and it works :)

Using Jenkins, how can a cascade of builds be triggered?

Using Jenkins, I am trying to arrange for the success of one build to trigger another build, so that there will be a cascade of builds until failure.
Given three projects (project1, project2, and project3), I am using Parameterized Trigger Plugin. How should I write the condition in the "Predefined parameters" field.
For example:
project1->success then trigger project2->success then trigger project3
In Jenkins I configure freestyle job.
Use a wrapper job of MultiJob type:
https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin
This will enable you to put each of your projects as a phase in the build and build the logic you need and much more
Look for the "Trigger when build is" Stable

Jenkins MultiJob Plugin does not aggregate downstream test results

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.

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