question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gradle 0.9.7 auth issue

See original GitHub issue

Description of the issue: When pushing the image to docker hub, a 401 unauthorized error occurs.

Expected behavior: When provided with valid authentication, the application should log in and push the image successfully.

Steps to reproduce: auth does not seem to be valid in build.gradle

Environment: Running within a Docker container created by Jenkins. Build takes place in Docker container gradle:4.9-jdk10

jib-gradle-plugin Configuration:

jib {
    from {
        image = 'openjdk:10-jre'
    }
    to {
        image = "techtony96/boltbot:$boltBotVersion-" + getCommitHash()
        auth {
            username = System.getenv("DOCKER_USR")
            password = System.getenv("DOCKER_PSW")
        }
    }
    container {
        jvmFlags = ['-Xms512m', '-Xmx512m']
        mainClass = 'com.discordbolt.boltbot.BoltBot'
    }
}

Log output:

+ gradle jib
> Task :compileJava UP-TO-DATE
> Task :processResources
> Task :defineProperties
> Task :classes

Containerizing application to techtony96/boltbot:3.0-SNAPSHOT-0816d3f...

Retrieving registry credentials for registry.hub.docker.com...
Getting base image openjdk:10-jre...
Building dependencies layer...
Building resources layer...
Building classes layer...
Building snapshot-dependencies layer...
Retrieving registry credentials for registry.hub.docker.com...
Finalizing...
Got more than one input Future failure. Logging failures after the first
com.google.cloud.tools.jib.registry.RegistryUnauthorizedException: Unauthorized for registry.hub.docker.com/techtony96/boltbot
	at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:218)
	at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:141)
	at com.google.cloud.tools.jib.registry.RegistryClient.callRegistryEndpoint(RegistryClient.java:338)
	at com.google.cloud.tools.jib.registry.RegistryClient.checkBlob(RegistryClient.java:249)
	at com.google.cloud.tools.jib.builder.steps.PushBlobStep.call(PushBlobStep.java:80)
	at com.google.cloud.tools.jib.builder.steps.PushBlobStep.call(PushBlobStep.java:35)
	at com.google.common.util.concurrent.CombinedFuture$CallableInterruptibleTask.runInterruptibly(CombinedFuture.java:181)
	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:57)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: com.google.api.client.http.HttpResponseException: 401 Unauthorized
	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1070)
	at com.google.cloud.tools.jib.http.Connection.send(Connection.java:130)
	at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:173)
	... 10 more
Got more than one input Future failure. Logging failures after the first

Additional Information: I get a warning from Intellij saying auth can not be resolved, which seems to me that my login info is not being used.

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:22 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
chanseokohcommented, Aug 1, 2018

Glad you figured it out. We also discovered a few issues around logs, so your detailed feedback was very helpful.

> Build image failed, perhaps you should set a credential helper name with the configuration 'from.credHelper' or from.auth

I did not have an auth field originally and got this error so I assumed I needed one and added it.

Seems like we are printing a wrong error message. Filed a bug: #758

Also filed another bug to print a warning if either the username or the password is null: #759

1reaction
chanseokohcommented, Jul 31, 2018

@Techtony96 @coollog I think there is actually something more to it. From the log, Jib says that it did not get the auth info from build.gradle, for both the from-image and the to-image.

Retrieving registry credentials for registry.hub.docker.com...
RUNNING	Retrieving registry credentials for registry.hub.docker.com
No credentials could be retrieved for registry registry.hub.docker.com
...
Retrieving registry credentials for registry.hub.docker.com...
RUNNING	Retrieving registry credentials for registry.hub.docker.com
No credentials could be retrieved for registry registry.hub.docker.com

Whether or not providing correct passwords or having the auth section for the from-image or the to-image, if the auth sections have any values, Jib should log that the values are being picked up:

Retrieving registry credentials for registry.hub.docker.com...
RUNNING Retrieving registry credentials for registry.hub.docker.com
Using jib.to.auth for registry.hub.docker.com
...
Retrieving registry credentials for registry.hub.docker.com...
RUNNING Retrieving registry credentials for registry.hub.docker.com
Using jib.from.auth for registry.hub.docker.com

The build.gradle that I’m testing looks like this:

jib {
  from {
    image = 'openjdk:10-jre'
    auth {
      username = 'chanseok'
      password = 'whatever'
    }
  }
  to {
    image = 'chanseok/image-built-with-jib'
    auth {
      username = 'chanseok'
      password = 'whatever'
    }
  }
}

Now, I am suspecting that System.getEnv('DOCKER_PASSWORD') is returning null. If I use the following build.gradle on my machine where UNDEFINED_VAR is not defined,

jib {
  from {
    image = 'openjdk:10-jre'
    auth {
      username = 'chanseok'
      password = System.getenv('UNDEFINED_VAR')
    }
  }
  to {
    image = 'chanseok/image-built-with-jib'
    auth {
      username = 'chanseok'
      password = System.getenv('UNDEFINED_VAR')
    }
  }
}

Jib ignores the auth section as the values are null and outputs the same error log as yours:

No credentials could be retrieved for registry registry.hub.docker.com
...
No credentials could be retrieved for registry registry.hub.docker.com

So I’m guessing the environment variable DOCKER_PASSWORD is not available inside build.gradle inside the Jenkins image.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gradle build not working for React Native project after ...
After doing this, I somehow managed to update the Android Gradle Plugin Version to 4.1.3 and Gradle Version to 6.9 under File >...
Read more >
[GRADLE-1222] Cannot authenticate on maven repository on ...
Two Ubuntu, two Windows XP/7 and one MAC. We save our credentials for authenticating on our nexus server(maven repository) in the gradle.properties in...
Read more >
Publish Artifacts from a Gradle Project - JetBrains
To publish artifacts of a Gradle project, you should configure artifact properties, reference a repository, and specify authentication ...
Read more >
Change Log - gradle refreshVersions - GitHub Pages
had an issue: its removal would not be taken into account until the Gradle daemon would be killed. This now behaves correctly. We...
Read more >
google/jib - Gitter
@briandealwis You commented on my issue about enabling Google HTTP logging. ... with -Djava.util.logging.config.file=log.properties when I call gradle jib?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found