Jenkins,Docker Build Step create image返回NullPointerException

时间:2016-07-29 14:46:00

标签: jenkins docker nullpointerexception dockerfile

我尝试创建一个生成DockerFile的作业并使用它创建一个docker镜像,我已经安装了Docker插件来执行这些步骤

我有一个构建步骤,应该创建一个像docker image creation and pull

这样的图像

然而,当我运行这份工作时,一切都很好,直到达到这一步,这将返回下面的错误

ERROR: Build step failed with exception
java.lang.NullPointerException
    at com.github.dockerjava.jaxrs.DockerCmdExecFactoryImpl.init(DockerCmdExecFactoryImpl.java:105)
    at com.github.dockerjava.core.DockerClientImpl.withDockerCmdExecFactory(DockerClientImpl.java:64)
    at com.github.dockerjava.core.DockerClientBuilder.build(DockerClientBuilder.java:63)
    at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.createDockerClient(DockerBuilder.java:132)
    at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.getDockerClient(DockerBuilder.java:204)
    at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder.perform(DockerBuilder.java:68)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson.model.Build$BuildExecution.build(Build.java:205)
    at hudson.model.Build$BuildExecution.doRun(Build.java:162)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
    at hudson.model.Run.execute(Run.java:1741)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Build step 'Execute Docker command' marked build as failure
Finished: FAILURE

我也尝试使用shell脚本并运行此行

docker build --pull=true -t registry.mywebsite.com:5000/sequoia-$VERSIONBUILD:$BUILD_NUMBER .

但它告诉我

docker not found

这意味着它没有Docker,所以我需要使用Docker插件

我的步骤有问题,还是我的配置有问题?

1 个答案:

答案 0 :(得分:1)

在运行此作业的任何从站(或主站)上,您需要在$ PATH中运行docker服务和docker二进制文件。

该插件只提供了一个Jenkins构建步骤来调用docker作为构建步骤而不是docker服务和二进制文件本身。您需要单独安装和设置它。

有关详细信息,请参阅https://wiki.jenkins-ci.org/display/JENKINS/Docker+build+step+plugin

上的“配置”部分