Need sudo in order to work?
See original GitHub issueDescription of the issue: When I run build Gradle task it fails, but when I run it with sudo it works
Expected behavior: Build task should work without sudo
Steps to reproduce:
- add jib to project
- run build
Environment:
- IntelliJ IDEA 2018.2
- Build #IU-182.3684.101, built on July 24, 2018
- JRE: 1.8.0_152-release-1248-b8 x86_64
- JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
- macOS 10.13.6
- Homebrew & cask 1.7.1
- Docker 18.06.0-ce-mac70 (26399)
- docker-credential-ecr-login 0.6
- docker-credential-osxkeychain 0.6
jib-gradle-plugin
Configuration:
buildscript {
ext {
kotlinVersion = '1.+'
springBootVersion = '2.+'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-noarg:${kotlinVersion}")
}
}
plugins {
id 'com.google.cloud.tools.jib' version '0.9.7'
}
def groupId = groupName
def artifactId = artifactName
def targetType = 'TC'
println "Gradle version: " + project.getGradle().getGradleVersion()
println "Groovy version: " + GroovySystem.getVersion()
description = "${groupId}:${artifactId}"
def buildNumber = System.properties['buildNumber'] ?: 0
def versionId = (buildNumber != null ? versionNumber + '-' + buildNumber : versionNumber + '-0') + '.' + targetType
def environment = System.properties['env'] ?: 'dev'
def nexusEnvironment = System.properties['nexus.environment'] != null ? System.properties['nexus.environment'] : 'CI'
println "Processing: ${description}"
println "Build version: ${versionId}"
group = groupId
version = versionId
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'maven'
apply plugin: 'kotlin-jpa'
sourceCompatibility = 10
compileKotlin {
kotlinOptions {
freeCompilerArgs = ["-Xjsr305=strict"]
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
freeCompilerArgs = ["-Xjsr305=strict"]
jvmTarget = "1.8"
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.github.spring-data-dynamodb:spring-data-dynamodb:+'
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile group: 'javax.xml.bind', name: 'jaxb-api'
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile 'com.amazonaws:aws-java-sdk:+'
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter')
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
compile("org.jetbrains.kotlin:kotlin-reflect")
testCompile('org.springframework.boot:spring-boot-starter-test') {
exclude module: 'junit'
}
testImplementation('org.junit.jupiter:junit-jupiter-api')
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine')
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: System.getProperties().nexusServer + "/content/repositories/${nexusEnvironment}") {
authentication(
userName: System.getProperties().nexusUsername,
password: System.getProperties().nexusPassword)
}
pom.groupId = groupId
pom.artifactId = artifactId
pom.version = versionId
}
}
}
test {
useJUnitPlatform()
}
jib.to.image = 'xxx.dkr.ecr.us-east-1.amazonaws.com/app:' + System.nanoTime()
tasks.build.dependsOn tasks.jib
Log output:
$ ./gradlew build
> Configure project :
Gradle version: 4.8
Groovy version: 2.4.12
Processing: com.corp.:app
Build version: 18.100.00-0.TC
warning: Base image 'gcr.io/distroless/java' does not use a specific image digest - build may not be reproducible
Containerizing application to xxx.dkr.ecr.us-east-1.amazonaws.com/app:16028421222531...
Retrieving registry credentials for xxx.dkr.ecr.us-east-1.amazonaws.com...
Getting base image gcr.io/distroless/java...
Building dependencies layer...
Building resources layer...
Building classes layer...
warning: The system does not have docker-credential-ecr-login CLI
Finalizing...
Got more than one input Future failure. Logging failures after the first
com.google.cloud.tools.jib.registry.RegistryUnauthorizedException: Unauthorized for xxx.dkr.ecr.us-east-1.amazonaws.com/app
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
com.google.cloud.tools.jib.registry.RegistryUnauthorizedException: Unauthorized for xxx.dkr.ecr.us-east-1.amazonaws.com/app
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
com.google.cloud.tools.jib.registry.RegistryUnauthorizedException: Unauthorized for xxx.dkr.ecr.us-east-1.amazonaws.com/app
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
com.google.cloud.tools.jib.registry.RegistryUnauthorizedException: Unauthorized for xxx.dkr.ecr.us-east-1.amazonaws.com/app
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
> Task :jib FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':jib'.
> Build image failed, perhaps you should set a credential helper name with the configuration 'to.credHelper' or to.auth
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
9 actionable tasks: 3 executed, 6 up-to-date
$ sudo ./gradlew build
Password:
> Configure project :
Gradle version: 4.8
Groovy version: 2.4.12
Processing: com.corp.:app
Build version: 18.100.00-0.TC
warning: Base image 'gcr.io/distroless/java' does not use a specific image digest - build may not be reproducible
Containerizing application to xxx.dkr.ecr.us-east-1.amazonaws.com/app:16056128877123...
Retrieving registry credentials for xxx.dkr.ecr.us-east-1.amazonaws.com...
Getting base image gcr.io/distroless/java...
Building dependencies layer...
Building resources layer...
Building classes layer...
Finalizing...
Container entrypoint set to [java, -cp, /app/libs/*:/app/resources/:/app/classes/, com.AppDomain.Application]
Built and pushed image as xxx.dkr.ecr.us-east-1.amazonaws.com/app:16056128877123
BUILD SUCCESSFUL in 5s
9 actionable tasks: 3 executed, 6 up-to-date
$ docker-credential-ecr-login version
0.6.0
$
Additional Information: I tried using Docker Hub and it couldn’t find docker credential helper, also tried reinstalling Docker and got same thing.
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (9 by maintainers)
Top Results From Across the Web
Is there a way to stop having to write 'sudo' for every little thing ...
Two options come to my mind: Own the directory you want by using chown : sudo chown your_username directory.
Read more >Unix/Linux Privilege Management: Should You Sudo?
With “sudo,” you continue to use your user account, but with root privilege, whereas in “su,” you are actually logged into the root...
Read more >Linux Sudo Command, How to Use With Examples
sudo is a powerful command in Linux that enables users to run commands with elevated privileges. Learn how to use this command with ......
Read more >How to Set Up and Manage Sudo Permissions - Liquid Web
Sudo is a Linux program meant to allow a user to use root privileges for a limited timeframe to users and log root...
Read more >Using sudo to delegate permissions in Linux | Enable Sysadmin
As a sysadmin, I can use the /etc/sudoers file to allow users or groups of users access to a single command, defined groups...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @briandealwis I took a look into my
.aws
files and got it fixed. My workplace uses multiple AWS CLI profiles and uses a script to get the MFA token, I guess it wasn’t updating the “default” profile’s keys with the ones in the token response so it wasn’t using the profile that had session access. I manually got a token withget-session-token
and pasted the session keys to my profile with access and it was able to get through. I cleaned out my profiles and reconfigured them and now I don’t have this problem anymore, even without manually updating the keys. @chanseokoh those commands returned the same thing, with different keys in all my profilesThanks for the update. It’s really helpful to know.