GoogleContainerTools / GoogleContainerTools/jib
skipExistingImages not working correctly?
- Dominant language
- Java
- Stars
- 14.5k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Environment**:
- *Jib version:* 3.4.3
- *Build tool:* gradle 8.10
- *OS:* Linux/macOS
**Description of the issue**:
`skipExistingImages` is supposed to make the error of having already pushed the image go away, but I still get:
```
Execution failed for task ':name:jib'.
> com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException:
Tried to push image manifest for blablabla.amazonaws.com/some/name:theversion but failed because:
Registry may not support pushing OCI Manifest or Docker Image Manifest Version 2, Schema 2
```
I've verified that `skipExistingImages` is correctly set to true when gradle is invoked by adding the following print in one of my `build.gradle.kts` files:
```kotlin
println("skip-existing: ${JibSystemProperties.skipExistingImages()}")
```
This prints `true`.
The problem typically occurs if there's some flakiness in the CI so a few of the images get pushed successfully, which during a retry will cause a failure due to already pushed images.
The workaround is ofc to just commit something which changes the hash used as tag allowing the build to complete, but it's an inconvenience compared to just retry.
**Expected behavior**:
Complete silence and exit 0, or some log that says the image already exists.
**Steps to reproduce**:
1. Create an immutable AWS ECR repository entry
2. Run `jib` task to push
* In my case this produces an _Image Index_ with the tag, plus two untagged _Image_ entries, one for each of arm64 and x64.
4. Repeat 2.
**`jib-gradle-plugin` Configuration**:
```kotlin
println("skip-existing: ${JibSystemProperties.skipExistingImages()}")
jib {
to {
image = "...:$commitHash"
credHelper.helper = "ecr-login"
}
from {
image = "amazoncorretto:17"
platforms {
platform {
architecture = "amd64"
os = "linux"
}
platform {
architecture = "arm64"
os = "linux"
}
}
}
container {
environment = mapOf(
...,
)
entrypoint = listOf("...")
labels.set(
mapOf(
"org.opencontainers.image.revision" to version,
"org.opencontainers.image.source" to "...",
),
)
}
extraDirectories {
paths {
path {
setFrom(layout.buildDirectory.dir("extra"))
into = "/app"
}
...
}
permissions.set(mapOf(
"..." to "755"
))
}
pluginExtensions {
pluginExtension {
implementation = "com.google.cloud.tools.jib.gradle.extension.layerfilter.JibLayerFilterExtension"
configuration(Action {
filters {
filter {
...
}
...
}
})
}
}
}
```
**Log output**:
```
Execution failed for task ':name:jib'.
> com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException:
Tried to push image manifest for blablabla.amazonaws.com/some/name:theversion but failed because:
Registry may not support pushing OCI Manifest or Docker Image Manifest Version 2, Schema 2
```
**Additional Information**:
Contributor guide
Assessment
This issue has not been assessed yet.