0

I downloaded the jenkins/jenkins:lts image from docker hub which I got up and running on Ubuntu 16.04. The image doesn't seem to include Ant or Maven, and may also want to do builds against different versions of the jdk. I am wondering what is the right way to adress this - can I just run bash on the container and run apt-get or yum as the case may be to install extra stuff needed for my builds, or is there a better way?

3 Answers 3

4

Jenkins can automatically install Maven and Ant.

First, install the Ant Plugin by going to Manage jenkins > Manage Plugin > Available and install the Ant Plugin.

Next go to Manage jenkins > Global tool configuration then add Maven and Ant.

Once a build requires Maven or Ant, they will be downloaded and installed.

0

Installing your tools directly in the running container is probably a bad idea as changes won't persist. Instead, I see the following options:

  1. Let jenkins manage your tools like proposed by yamenk
  2. Clone the jenkinsci docker repository and build your custom jenkins image including build tools you need
  3. Run build jobs in docker containers

I used option 3 with success just recently:

  • Run build jobs inside docker containers (look into Jenkins pipeline plugin, or just run it from a shell step)
  • Each build container has a single responsibility and provides all the tools your build environment needs
  • Support for different tools and versions is unlimited; new technologies can be added in no time
3
  • I'm not quite sure what you mean by option 3 - do you mean set up multiple build environments (with different versions of the JVM for example) in containers separate from the Jenkins one? How would Jenkins initiate a build command in one of these containers?
    – Shane
    Oct 31, 2017 at 11:23
  • Yes, that's exactly what I mean. The only new dependency for the jenkins container is a docker client and the host's docker socket mounted into it.
    – tworabbits
    Oct 31, 2017 at 13:37
  • You can also persist jenkins data by mounting the /var/jenkins_home folder.
    – sridesmet
    May 30, 2018 at 14:49
0

Another (more tricky) alternative is it to use Docker Containers for your tools.

I can recommend the following two articles:

https://jenkins.io/blog/2016/08/08/docker-pipeline-environments/

https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.