1

I have a some Jobs running on jenkins that has several nodes.
In the past I forced all my jobs to run all on the same node.
Now for purpose of load distribution I would like to reduce this constraints. But sometimes I need one Job that is triggered by another to run on the same node. This triggered Job can be triggered by any job (with different parameters) but if this is triggered by a Job it should run on the same node.
e.g.:
Triggered Job = Job_T
Any Jobs: Job1, Job2, Job3

Node X: Run Job1 -> Job_T(Job1)
Node Y: Run Job2 -> Job_T(Job2)
Node X: Run Job3 -> Job_T(Job3)

Is this possible to configure in the Jenkins Jobs?

StephenKing
  • 36,187
  • 11
  • 83
  • 112
PaulEdison
  • 897
  • 1
  • 15
  • 36

1 Answers1

2

Parameterize your jobs if they are not already. Pass the parent job node label as parameter to the downstream (triggered) job

ben5556
  • 2,915
  • 2
  • 11
  • 16
  • I understand that I can pass the variable to the triggered Job but how do I use it there as a variable? Ad could I have a default if the parameter was not provided? – PaulEdison Oct 15 '18 at 16:47
  • Please see my answer on another post - https://stackoverflow.com/a/52807254/7983309 – ben5556 Oct 15 '18 at 18:33
  • Yes, you can have a default value if paraneter is not provided. If you need example pipeline code let me know – ben5556 Oct 15 '18 at 18:36
  • It seems the linked answer is for piplined Jobs - unfortunately I don't have that here. so it seems to not work that way :( So the question is if I can use the variables and other expressions as well in the node label constrain configuration field of the jenkins job. – PaulEdison Oct 18 '18 at 00:33
  • How are you running your jobs ? – ben5556 Oct 18 '18 at 04:21
  • triggered manually or a scheduled on a time base - but I now found an option for running a triggered job on the same node (this is even overriding the constrains that are configured for that job) - I've to check if this is working well. – PaulEdison Oct 20 '18 at 19:36