Jenkins Kubernetes Agents

Hi,
We have setup jenkins in kubernetes cluster. In a pipeline we are calling an agent, actually this agent contains 3 containers of which 1 container can be used by next stage. But the problem is since I’m mentioning agent in every stage, each stage pulls new image which in return increase build time, how will I rectify this so that the build time can be decreased.

We use a total of 4 different agents for a pipeline.

Thanks,
Alexy

I assume from your question that you are using declarative pipelines

I am not an expert in declarative pipelines, but I think in your case instead of calling agent every time, you can just select the container you want to run in

so:

  1. you call agent once ( and that agent is a pod with multiple container )
  2. then you select the container where you want to run steps

there is an example in the documentation, that can help you: