extend jenkins image to install maven

xetra11 picture xetra11 · Sep 5, 2017 · Viewed 13.3k times · Source

I'm using the jenkins/jenkins:lts image at the moment. It runs fine and does everything I want to expect one thing. I want it to run Maven goals in the build steps. The problem is that there is not maven installed in the jenkins container environment.

So I want to extend the mentioned image to run an apt-get install maven.

My solution:

FROM "jenkins/jenkins:lts
USER root
RUN /bin/bash -c "apt-get install maven"

Will this be enough? I assume that all RUN and ENTRYPOINT steps of the jenkins image will run by itself and I do not need to re-execute them in my Dockerfile right?

Answer

Bukharov Sergey picture Bukharov Sergey · Sep 5, 2017

you need to update package cache before install, and don't miss -y for apt-get install.

FROM jenkins/jenkins:lts
RUN apt-get update && apt-get install -y maven