GoogleContainerTools / GoogleContainerTools/jib

Allow changing existing jib images without the "package" maven goal having run

Open
#4,272 0 comments 2 reactions 0 assignees View on GitHub
priority: p2 type: feature request
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:* Maven 3.9.7
- *OS:* Linux

**Description of the issue**:

While getting CDS to work with[ containerizingMode `packaged` & jib works](https://github.com/GoogleContainerTools/jib/issues/2471#issuecomment-2154859406), there's a task where I simply want to add a file to an existing Jib container.

When I simply run:

```
./mvnw -Drevision="${VERSION}" \
-Djib.to.image="${DOCKER_IMAGE}:${VERSION}" \
-Djib.from.image="${DOCKER_IMAGE}:${VERSION}" \
-Djib.extraDirectories.paths=./cds_output \
-Djib.container.jvmFlags=-XX:SharedArchiveFile=/application.jsa \ # <3>
jib:build
```

I get the error:

```
Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.4.3:build (default-cli) on project cdstestng-app: Obtaining project build output files failed; make sure you have packaged your project before trying to build the image. (Did you accidentally run "mvn clean jib:build" instead of "mvn clean package jib:build"?):
```

This makes perfect sense in the traditional setup of building an application and then containerizing, but because I'm using Jib to perform 3 actions (build, run to generate the cds data, insert the cds data into previously built image), I run into having to have the build artifacts from the first action, despite there not being a strict need for these files (as far as I'm aware) because we already have access to the container image.

One can run into this issue when there's a CICD pipeline where these actions are split into jobs, each with their own clean environment. Because of this issue, I have to explicitly configure the pipeline to bring the artifacts from the build action (job) to the final action (job) just to get Jib to run.

**Expected behavior**:

It would be great for the CDS use case if Jib could modify an existing image, without an artificial (?) requirement on a previous maven phase having run.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.