Regarding docker elastic agent

35 views
Skip to first unread message

Vijayakumaran A.

unread,
Aug 15, 2023, 8:31:16 AM8/15/23
to go-cd
Hi Team,

I have set up a docker elastic agent using docker plugin and created a cluster profile with one elastic profile using maven:3.6.3-openjdk-11 docker image.

i have one pipeline with one stage build maven job,i wanted to perform just checkout the code and mvn clean install using elastic agent,and i wanted to save generted build artifact.i have given elastic agent profile ID in this job.when i run the pipeline it started created maven:3.6.3-openjdk-11 docker image after one sec the container status  automatically exited.i don't know why.Can i need to change any other docker images are what steps i need to make this works. please anyone help me to build my pipeline.

Thanks

Ashwanth Kumar

unread,
Aug 15, 2023, 12:53:08 PM8/15/23
to go...@googlegroups.com
I think you need to use a gocd-agent image that is baked from maven image. The agent image when started should register with gocd server and have an actual agent running. In your case the image is trying to run mvn command on startup and exits quickly.

I can understand if you're new to this elastic agent setup on gocd this can be confusing but hopefully this is a one time learning.

Thanks,

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/04c54e9e-6926-4d25-9e3d-f121d4230920n%40googlegroups.com.

Vijayakumaran A.

unread,
Aug 15, 2023, 1:24:44 PM8/15/23
to go-cd
Thanks.i have changed image with gocd/gocd-agent-ubuntu-22.04:v23.3.0 to build job (mvn clean install) but got maven not installed error.
  /bin/bash -c "mvn install"took: 0.113sexited: 127
/bin/bash: line 1: mvn: command not found

JQ

unread,
Aug 16, 2023, 11:18:19 AM8/16/23
to go-cd
There are generally two approaches you could use to solve this.

1. Dockerize your workflow and run everything on DinD (Docker-in-docker) agents (official image here: https://hub.docker.com/r/gocd/gocd-agent-docker-dind/tags/)
  - 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
JQ
Reply all
Reply to author
Forward
0 new messages