I am trying to prove that Jenkins is running in a container built from the official docker hub jenkins image.
require "serverspec"
require "docker"
describe "Dockerfile" do
before(:all) do
image = Docker::Image.build_from_dir('./images/jenkins')
set :os, family: :debian
set :backend, :docker
set :docker_image, image.id
end
describe process("java") do
it { should be_running }
end
end
I get the following result:
Failures:
1) Dockerfile Process "java" should be running
Failure/Error: it { should be_running }
expected Process "java" to be running
# ./spec_jenkins.rb:24:in `block (3 levels) in <top (required)>'
Am I misunderstanding that tests are run against a container instantiated from the built image ?
The official Jenkins image defines an
ENTRYPOINT
rather than aCMD
.However,
specinfra
looks for aCMD
and uses/bin/sh
if it does not find any.IOW, specinfra does not run Jenkins. Reason why my test was failing.
By specifying proper
docker_container_create_options
,specinfra
also starts Jenkins and the test passes.Working code: