-
Bug
-
Resolution: Fixed
-
Major
-
docker plugin 0.16.2
jenkins 2.7
insecure docker registry and docker hosts
If you have credentials == None and a "Build / Publish Docker Containers" build step then, when the build step executes, you get a NullPointerException:
Docker Build ERROR: Build step failed with exception java.lang.NullPointerException at com.nirima.jenkins.plugins.docker.utils.JenkinsUtils.makeAuthConfig(JenkinsUtils.java:173) at com.nirima.jenkins.plugins.docker.utils.JenkinsUtils.getAuthConfigurations(JenkinsUtils.java:150) at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher$Run.buildImage(DockerBuilderPublisher.java:273) at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher$Run.run(DockerBuilderPublisher.java:230) at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher.perform(DockerBuilderPublisher.java:361) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78) 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 'Build / Publish Docker Containers' marked build as failure
My docker host is "insecure", hence my docker cloud definition is set to have credentials==None, as does my registry.
This means that when JenkinsUtils.makeAuthConfig(Credentials) runs, credentials is not instanceof StandardUsernamePasswordCredentials and hence null is returned to makeAuthConfig(DockerRegistry) which then de-references the null and explodes.
A potential fix is to edit
JenkinsUtils.java
protected static AuthConfig makeAuthConfig(DockerRegistry registry) { if( registry == null ) return null; Credentials credentials = lookupSystemCredentials(registry.credentialsId); return makeAuthConfig(credentials).withRegistryAddress(registry.registry); }
to be
JenkinsUtils.java, modified
protected static AuthConfig makeAuthConfig(DockerRegistry registry) { if( registry == null ) return null; Credentials credentials = lookupSystemCredentials(registry.credentialsId); final AuthConfig authConfig = makeAuthConfig(credentials); if( authConfig == null ) return null; return authConfig.withRegistryAddress(registry.registry); }