0

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 pod 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.

  • Please let me know whether the shared info was helpful. I am happy to assist if you have any further queries. If the provided information was helpful,you can check this link. [What should I do when someone answers my question](https://stackoverflow.com/help/someone-answers)? – Fariya Rahmat Aug 23 '23 at 03:37
  • I am looking forward to your feedback to understand whether the provided resolution has helped you in resolving the issue. If not, I am happy to assist further. – Fariya Rahmat Sep 01 '23 at 06:06
  • Hi, thanks a lot for the suggestion, I couldn't look into this. Will check and add my findings. – Alexy Pulivelil Sep 01 '23 at 06:21

1 Answers1

0

You can attach a shared persistent volume to the build container to speed up the build process and If you are using Jenkins & kubernetes, you should definitely try out the container-based agents. Scaling your jenkins agents on kubernetes helps you from a lot of administrative overhead that you get with static build VMs.

The below information extracted from the document authored by Bibin Wilson might be helpful to you:

For example, if you take a Java application, it has many Maven package dependencies.

When you build the Java apps, it downloads dependencies added in the pom.xml from the remote maven repository the first time, and it creates a local .m2 cache directory where the dependent packages are cached.

The .m2 cache is not possible in Docker agent-based builds as it gets destroyed after the build.

We can create a persistent volume for the maven cache and attach it to the agent pod via the container template to solve this issue.

Fariya Rahmat
  • 2,123
  • 3
  • 11