Running different jobs on different nodes in Jenkins in parallel - jenkins

I am new in Jenkins and looking for an easy solution:
I have about 10 jobs and about 4 nodes and would like to run all the jobs on different nodes. I want the jobs to run simultaneously, when a node is free then a job that didn't run yet should run on it.
What I did is that I gave a label to each node and on the jobs I set to run on label. I added a job X that not do anything, and in the jobs that I want to run I set to run after the job X finished. This solved the issue.
My problem now is I want to send report in mail after all the jobs are done but I dont have a way knowing when they are done. I tried using pipeline with stages, but even with pipeline it does only trigger the jobs but I cannot know when they are done. Any suggestions?

You can use this plugin to do that. After you add that plugin to Jenkins just do a "New Item -> Multijob Project" from Jenkins home and configure the jobs to run parallel and then you can send mail using this plugin

Related

Force Jenkins to run only one pipeline job and put rest all in queue

I would like to build only one project at a time in entire jenkins server. I have tried Jenkins throttle concurrent plugin and lockable resource plugin but no luck. As lockable resource plugin doesn't give me option to lock in pipeline job.
I have 3 Jenkins pipeline jobs (job have pipeline script):
JOB1
JOB2
JOB3
which has some common thing at beginning of the job (clearing content).
Running one by one manually doesn't have any problem if job completed but if JOB1 is building and JOB2 starts in between then it interrupts to JOB1 and build fails for JOB1.
Even when I start jobs using CLI, you never know which job might be running. So, I'm looking for solution to block JOBY if JOBX is running (X, Y can be 1,2 or 3) and allow only one job to run in entire Jenkins server. Like I said, throttle concurrent plugin gives customization option only for respective job instead of for multiple jobs?
Can anyone suggest some solution for multi pipeline jobs block to run only once?
Install Build Blocker Plugin
In configuration of JOBY check "Block build if certain jobs are running".
Put JOBX name in Blocking Jobs text area, each job on new line.
Note, you can also use regex to define in single line jobs having the same prefix but ending with different numbers.

Jenkins - How to run one housekeeping job on all nodes (slaves + master)

I have Jenkins setup of 6 Slaves and master, all windows machines. Now I have a housekeeping Jenkins job which I want to periodically run on all the slaves and master, as this job does following tasks
Delete unused temporary files.
Delete unwanted processes, as some of the tests are leaking processes (why leak is different question).
Set certain environment variables, as sometimes I want to push environment variable changes to all machines.
Any idea how can I force Jenkins to run this one job on all slaves and master once every day? As a work around I can create multiple Jenkins job and mark each one to run on one particular slave or master, but I would rather avoid having so many duplicate jobs.
The Node and Label Parameter plugin allows you to parameterize where a job should be run. The job can be run on more than one node -- each node shows up as a separate execution in the job's build history. When multiple nodes are selected, you can configure whether the job should continue to run on other nodes if an execution fails.
I had a similar need, but using the Node and Label Parameter Plugin didn't seem quite right, as I do not want to parameterize my cleanup jobs.
I found a more satisfying answer in this post and thought it would also benefit to this question: Jenkins - Running a single job in master as well as slave.
Here is some documentation on how to configure a "Matrix project": https://wiki.jenkins.io/display/JENKINS/Building+a+matrix+project.
What you are looking for is the "Slave axis". It's not very well documented in the page above, but it appears as an option of the "Add axis" menu whenever there are more than one node. Here's a screenshot of the interesting part:
Updates according to recent Jenkins
Pipeline type:
On "Configuration" page for pipeline:

Jenkins multijob plugin doesn't execute in parallel the same job on different nodes

I configured in MultiJob plugin to have one phase, with the same job running on 2 different nodes.
e.g.
Download Files for Node LINUXVM
Download Files for Node WINDOWSVM
However, these jobs are not being run in parallel as you can see from the screen shot. the job itself waits for the previous one to finish although it's on different node
Is it possible to call the same jobs, but since it's on different nodes, that they will run in parallel?
You probably want to set the inner job (Download...) to execute current builds if necessary

run multi job of multi jobs on jenkins

I want to build multiple jobs in jenkins:
I install multi job plugin on jenkins. When I build test_all_jobs, it run job1 and freeze on it and doesn't start job1-1 until I close job1 test!
Actually I want to start job1-1 then job 1-2 and after they finished job 2-1 then job2-2 should start.
I should say I can not use Build Flow Plugin.
Thanks.
I don't use the multi job plugin. Instead, I use the combination of the Conditional BuildStep Plugin and the Parameterized Trigger Plugin.
I think together, you get much more flexibility and ease of configuring your desired flow.
Look into these and see if you can get the answer you want from joining them.
I hope this helps.
I guess this issue is because of the number of executors assigned to the slave node on which you are running the job is assigned with 1.
Under nodes---->select your node ----> Configure ---> Increase the no of executors
Hopefully this helps you.

Jenkins Build Distribution among Slaves

I need to get some advice about the way to control the way Jenkins Slaves are used / Jobs are being triggered.
Background / Constraints:
I have a sequence of 10 jobs that run one after each other using the "Trigger parameterized build on other projects" option Parameterized Trigger Plugin.
Each Build of these jobs must run on the same node (I am doing it by using "Build on the same node" which is also configured in the parameterized build plugin and comes from the NodeLabel Plugin).
I have 5 Slaves (current number of executors per slave is 1 but i am open for suggestions here...)
Once Slave is occupied by a Build Sequence, no other job can run on it. When I had only 1 slave, the way I enforced it was using the "Block build when downstream project is building"
The way I configured the slave to be chosen when the first Job is triggered is one of the following: (None of them solved my problem)
a. Using the "Restrict where this project can be run" and put there a label that all relevant slaves will point to.
b. Using the option of "This build is parameterized" (Parameterized Trigger Plugin) and then add a "Node" parameter with the list of Slaves that the User can choose from.
What I want to achieve?
When a User triger the build of the First Job in the Build Sequence, this Build will be done on once of the idle Slaves. (I mean a slave that is doing nothing at the moment)
If there are no idle slaves, then it will join a queue of one of them (doesn't matter which)
Any suggestions how to solve it?
Thanks!
Try passing ${NODE_NAME} as a NodeLabel as a post-build trigger to the downstream jobs. If that works, you may need to pass it every job.
Try node-label parameter plugin. you can make Jobs to run slave node which is free at that movement

Resources