Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature for printing name of image #1725

Open
trpouh opened this issue Nov 17, 2023 · 2 comments
Open

Add feature for printing name of image #1725

trpouh opened this issue Nov 17, 2023 · 2 comments

Comments

@trpouh
Copy link

trpouh commented Nov 17, 2023

Description

Add a feature (e.g. docker.image) that prints the name of the resolved image name.

Info

In our pipeline we use the docker-maven-plugin to build a docker image with docker-build. The subsequent job conducts a security scan of the previously build image with Trivy. However there seems to be no intuitive/stable way of passing the docker image name to trivy (or extract it at all).

possible options we evaluated: regex parsing the build output, mvn help:evaluate the artifact name/plugin config

I suggest implementing a feature (e.g. docker:build -DprintOnly) that resolves all possible flags that can be configured for the Image Name and prints the image name to the console.

A workflow could then look something like the following (simplified for reading purposse):

mvn docker:build
image = $(mvn docker:build -q -DprintOnly)

trivy image $image

If this feature is considered useful, I'd be more than happy to implement this feature myself!

@rohanKanojia
Copy link
Member

Umm, If I understand correctly are you asking for printing name of the image built by docker maven plugin? Isn't it something we're doing already? I'm able to see the image name during a normal image build like this:

[INFO] DOCKER> [username/dmp-demo-project:foo] "dockerfile": Built image sha256:d0c66
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  20.744 s
[INFO] Finished at: 2023-11-17T19:41:32+05:30
[INFO] ------------------------------------------------------------------------

@trpouh
Copy link
Author

trpouh commented Nov 17, 2023

Yes but the only way to extract the image name is by using a regex, which can cause some trouble when using different shells (pipeline vs locally - at least in my experience) and could potentially break if the output of the docker command changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants