Running jenkins jobs on any available slave - jenkins

Can someone please let me know how do I run a job on any available Jenkins cloud slave? I have tried assigning the same label to all 4 slaves but only the first slave is spinning up. I do not want to explicitly specify each slave label in the declarative pipeline. I have looked a lot but cannot find a resolution. I don't want to execute jobs on the master node. Any help would be appreciated, many thanks in advance!

Related

Prevent jobs from running on jenkins slave if a job of slave's own pipeline is running on it

I have master jenkins and slave jenkins. I hav kept slave jenkins no of build executors as 1. Slave Jenkins also has 1 pipeline (Lets say pipeline A).
lets suppose a job from slave jenkins' own pipeline is running right now (Job A). I schedule a job from the master jenkins for slave jenkins (Job B).
I dont want Job B to run while job A is running as both jobs use shared resources.
Right now, Job B runs in parallel with Job A, which is causing Job A to fail.
How to do that?
Thanks!
Your implementation is a bit tricky since you are talking about 2 separate machines with 2 separate Jenkins instances. One option is to get rid of the Jenkins instance in the slave machine and move the Jenkins job that runs on it to the master machine. Then, you can schedule the job to use the resources of the slave machine while being managed by the master machine. If you do that, no further configuration will be needed since you have set the number of executors to 1.
If that is not possible, the other option is to find a way for them to communicate with each other that a build is running. Consider the third point of this answer. You can have a variable in a database somewhere and when one job starts, it updates the variable. Before the second job starts, it has to poll the variable to see if there is a job already running. If yes, the build doesn't start, if no, build starts and updates the variable.
Another less elegant solution is to simply have a text file in a location accessible to both machines and write the variable data into that instead of a database.
One way to do this is by using the Lockable Resources Plugin.

Jenkins Per Slave Pipeline Build Enforcement

I'm trying to find a way to ensure that an entire pipeline completes on a specific executor without allowing other jobs to be run on that executor:
my pipeline essentially looks like:
Build -> Deploy -> API testing -> selenium testing
as we have multiple teams, all running multiple paralell pipelines i want to ensure that on a per slave basis all builds complete in the pipeline before any others begin
Is anyone aware of a plugin that does this?
You can look into the Locks and Latches plugin that can help you enforce this by assigning a lock to the relevant pipeline.
I have never tried your setup, but it might work.
Also, consider restricting the number of executors on the slave to 1, so only a single pipeline can "fit in".
I hope this helps.

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 trigger build on another slave

Consider this scenario -> I have 2 Jenkins slave Slave1 and Slave2, running jobs DeployJob1 and DeployJob2 respectively.
Here is my requirement -> whenever DeployJob1 finishes successfully I want to trigger DeployJob2.
Now, the problem is that we are on 2 different slaves. Is there a plugin which can help with this?
Note: I have already tried Parameterized Trigger Plugin but that only helps in case second job is on same slave.
Thanks in advance.
You should be able to achieve this with the Parameterized Remote Trigger Plugin by pointing it at your master and tying DeployJob2 to Slave2 in its configuration (if it's not already)
https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Remote+Trigger+Plugin

CI with Jenkins: how to force building happen on slaves instead of master?

I am using Jenkins for CI, I have a master and two slaves, master is running Jenkins and I want only slaves doing the actual building task, is there anywhere I can configure this? I know there is an 'executor', if I change it to 0 on master, probably master won't build anything, but is there any proper way to do this?
You can set where a job will be run using the "Restrict where this project can be run" option in your job.
This setting can be used together with tags you have added to your slaves.
For example two slaves having the tag "Linux-buildserver" and using that tag will split the job up on those two slaves.
Setting the IP-address as a tag in the job will make sure only that buildserver / slave is used.
One of my first steps in setting up a new Jenkins master is to do what you mention in your question, set "executors" to zero in the master server config.
This prevents anything from ever building on master.
While configuring the node, there is option,"leave this machine for tied jobs only" .if "leave this machine for tied jobs only" option is selected Then the slaves will be used by the jobs which are restricted to run on it.
The better way to do this is to give the master a label and restrict what runs on the master that way each of your builds don't have to specify a label.

Resources