Issue
I have a multimodule project that I am trying to use gradle 7.5.1 and jib to build and deploy each service artifact to ECR.
I have a ~/.docker/config.json file
{
"credsStore": "desktop"
}
{
"credHelpers": {
"public.ecr.aws": "ecr-login",
"xxxxxxx.dkr.ecr.us-east-1.amazonaws.com": "ecr-login"
}
}
and my AWS keys are in ~/.aws/credentials
Each of my modules has a settings.gradle that defines the rootProject.name to be the service (artifactId), as well as the plugin 'maven-publish'.
In my main project I have a build.gradle:
plugins {
id 'java'
id 'groovy'
id 'com.google.cloud.tools.jib' version '3.3.0'
id 'maven-publish'
}
..
jib {
from {
image = 'azul/zulu-openjdk:17-jre'
}
to {
image = 'xxxxxxx.dkr.ecr.us-east-1.amazonaws.com/${rootProject.name}'
// I have also tried image = 'xxxxxxx.dkr.ecr.us-east-1.amazonaws.com/${artifactId}'
}
}
When I try to build them via gradle jib I get the following error:
> Task :jib FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':jib'.
> Invalid image reference xxxxxxx.dkr.ecr.us-east-1.amazonaws.com/${rootProject.name}, perhaps you should check that the reference is formatted correctly according to https://docs.docker.com/engine/reference/commandline/tag/#extended-description
For example, slash-separated name components cannot have uppercase letters
The stacktrace also mentioned the invalid reference.
I am following several tutorials and the Google jib documentation, but I do not see what I am doing wrong - anyone else know?
Solution
Use double quotes instead of single quotes to make Gradle expand properties.
Answered By - Chanseok Oh
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)