I am trying to use Jenkins to build a C++ project in a Docker container. I have no problem building in Jenkins, or building in a container outside of Jenkins.
Below is what I tried. I am omitting the volumes mapping for clarity.
The following command successfully runs a build in a shell.
docker run --rm --interactive=true --tty=true $IMAGE make
However when run in Jenkins as an "execute shell" step Docker returns the following error.
cannot enable tty mode on non tty input
The following command is similar to the previous one but disables interactivity.
docker run --rm $IMAGE make
Jenkins can run a build successfully. However there are serious issues when aborting a build. The build is immediately marked as aborted but the container keeps running until the build completes. Also the container is not removed after exiting.
When run in a shell the command builds successfully but it is not possible to interrupt it. Also the container is removed after exiting.
Would anyone know how to cleanly run builds in Docker containers from Jenkins and retain the capability to abort builds?
Using any of the Jenkins plugins is not an option because the Docker calls are inside scripts and cannot be extracted easily.