How to execute single Jenkins job on multiple platforms with different parameters? - jenkins

I have created one build job in Jenkins. I want to use that same job to run on multiple nodes but with different job parameter.

You can use https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin
Create a new multyjob job, in the build section create a Multijob phase, and trigger your job with "Pre defined parameters" and "Node label parameter" to specify the node to run on, and the values of the parameters you want to trigger your job with.
Good luck!

Related

Build Jenkins job with Build periodically option with different argument

I have a Jenkins job which accepts only BranchName(bitbucket) as an input parameter.
I have scheduled this Job to run every morning 7 AM with Build periodically option H 7 * * *.
On triggering automatically, it takes default input parameter as development.
Now my requirement is that I need to pass few other branch names as input parameter automatically.
One option I tried it Down stream job with other branch name, but that works only from one branch and not a sophisticated solution.
Is there an easy way I can achieve this?
Job Configuration
If you only want to run a known set of branches you can either:
Create an upstream job for every branch that triggers the build with different parameters.
Create one upstream job, that utilize an list, loop over that list and execute the jobs in parallel.
If you need to get the list of branches dynamically, I would assume, that running sh script: 'git branch', returnStdout: true and some Groovy string split operation is the easiest way to archive that.

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 trigger a downstream job if a condition is met in Jenkins

I have a multiphase job CD which has two downstream Job CD-Sim CD-Art, I want trigger the jobs based on condition. if deploy = Art then trigger CD-Art this job and if deploy = Sim then trigger CD-Sim job..
How can i accomplish this using shell script by using execute shell option?
If your deploy condition can be evaluated with an environment variable ($DEPLOY for example), you can use the Conditional BuildStep plugin.
You have to create two conditional steps like below:
Plus another one to launch the CD-sim job if $DEPLOY=sim

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

In Jenkins how to trigger another build job based on the build parameter passed to current build job?

I have build jobs like a-build, a-deploy. b-build, b-deploy.
*-deploy are downstream job for *-build jobs. So they look like,
a-build
|
+-a-deploy
b-build
|
+-b-deploy
Now I have another job X-build. It accepts a-build, b-build etc as a parameter. So I if I run X-build with a-build as parameter it should complete with a post build action that triggers a-deploy. How can that be done?
You can accomplish this quite easily if you receive the job name in a parameter.
You can then use "Call/Trigger Builds on Other Projects" step, and use the Parameter you receive in the job name:
If the step is not available to you via Post Build menu, you can get to it via "Execute set of scripts" post-build step.

Resources