There are generally two approaches you could use to solve this.
- This means you build a docker image with your app and the necessary maven dependencies (eg. based on your maven:3.6.3-openjdk-11 docker image mentioned above), and use the DinD image above as your GoCD elastic agent image. Then your pipeline task runs the maven docker image to do the maven install. So the maven install happens on your maven docker container, which is running on your GoCD agent docker container.
- The caveat of this approach is that it requires running your GoCD agents in privileged mode for DinD to work. But if you have a dockerized workflow anyway, and need to build docker images in your pipelines, you'd typically need to run DinD anyway.
2. Build your custom GoCD agent image with the necessary dependencies installed. For example, use gocd/gocd-agent-ubuntu-22.04:v23.3.0 as your base image and install maven etc, and use that final custom image as the GoCD elastic agent image.Then, your pipeline task should be able. to run the maven install command directly on the agent.
Hope this helps