Search code examples
kubernetesjenkinsjenkins-agent

Can each of Jenkins-slave(kubernetes pod) to be bound to one build job while keep it alive even finished the job


We are using kubernetes plugin for Jenkins to construct a special CI system. We want to achieve that:

  1. For a given build job(named job_A), it will be built more than one time;

  2. We hope this job job_A to be bound to a specific jenkins-slave(named pod_A), and the pod_A should only provide service for job_A.

  3. After the job_A finished the build, pod_A should keep alive for the period of time time_T;

  4. During the time_T, the pod_A should not build other jobs even through it is idle.

  5. After another time interval which is less than time_T(the pod_A is still alive), we want to re-build the job_A, it will be send to pod_A and be build there.

Is there any way to achieve this?


Solution

  • In the PodTemplate definition there is an option idle time Time in minutes to retain slave when idle (time_T) that you can set to a large value.

    Then set the label of the pod template to a unique value and same label in your job. That way that pod will only take builds of that job