2

I'm working with a Jenkins install I've inherited. This install has the CloudBees Docker Custom Build Environment Plugin installed. We think this plugin gives us a nifty Build inside a Docker container checkbox in our build configuration. When we configure jobs with this option, it looks like (based on Jenkins console output) Jenkins runs the build with the following command

Docker container 548ab230991a452af639deed5eccb304026105804b38194d98250583bd7bb83q started to host the build
[WIP-Tests] $ docker exec -t 548ab230991a452af639deed5eccb304026105804b38194d98250583bd7bb83q /bin/sh -xe /tmp/hudson7939624860798651072.sh

However -- we've found that this runs /bin/sh with a very limited set of environmental variables -- including a $PATH that doesn't include /bin! So

  1. How does the CloudBees Docker Custom Build Environment Plugin setup its /bin/sh environment. Is this user configurable via the UI (if so, where?)

  2. It looks like Jenkins is using docker exec -- which i think means that it must have (invisibly) setup a container with a long running process using docker run. Doesn't anyone know how the CloudBees Docker Custom Build Environment Plugin plugin invokes docker run, and if this is user manageable?

Alana Storm
  • 164,128
  • 91
  • 395
  • 599

1 Answers1

1

Considering this plugin is "up for adoption", I would recommend the official JENKINS/Docker Pipeline Plugin.

It source code show very few recent commits.

But don't forget any container has a default entrypoint set to /bin/sh

ENTRYPOINT ["/bin/sh", "-c"]

Then:

https://wiki.jenkins.io/download/attachments/78676506/Capture%20d%E2%80%99%C3%A9cran%202015-06-25%20%C3%A0%2018.07.49.png?version=1&modificationDate=1435248491000&api=v2

The docker container is ran after SCM has been checked-out into a slave workspace, then all later build commands are executed within the container thanks to docker exec introduced in Docker 1.3

That means the image you will be pulling or building/running must have a shell, to allow the docker exec to execute a command in it.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • +1 Thank you for the tip on the Pipeline plugin -- politics may prevent that from being used on this specific project, but it sounds like something I might be able to use on a future project. Also, thank you for the info on docker exec. Per the original question, we are aware that jenkins uses docker exec -- however, in order for docker exec to work there needs to be an already running, not exiting container -- we're ultimately interested in knowing how the cloudbees plugin kicks all that off. – Alana Storm Dec 19 '17 at 22:51