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 documentation tip showing how to configure publishRegistry maven properties from the command line #31024

Closed
ffroliva opened this issue May 13, 2022 · 8 comments
Labels
status: superseded An issue that has been superseded by another

Comments

@ffroliva
Copy link

If I have a private registry and I want to publish the generated docker image I need to provide username, password, and url in the maven pom.xml.

...
<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration>
    <image>
      <name>${docker.image.prefix}/${project.artifactId}:${project.version}</name>
    </image>
    <docker>
      <publishRegistry>
        <username>USERNAME</username>
        <password>PASSWORD</password>
        <url>URL</url>
      </publishRegistry>
    </docker>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>build-image</goal>
      </goals>
    </execution>
  </executions>
</plugin>

I would like to be able to send this variables over the command line as follows:

mvn spring-boot:build-image \
-DskipTests \
-Dspring-boot.build-image.imageName=nexus:8870/rcl/op-risk-ui:test \
-Dspring-boot.build-image.publishRegistry.username=<USERNAME> \
-Dspring-boot.build-image.publishRegistry.password=<PASSWORD>
-Dspring-boot.build-image.publishRegistry.url=<URL>

Currently the following variables doesnt exist for the command line:

  • -Dspring-boot.build-image.publishRegistry.username
  • -Dspring-boot.build-image.publishRegistry.password
  • Dspring-boot.build-image.publishRegistry.url

I believe they should be created here:
https://github.com/spring-projects/spring-boot/blob/82b90d57496ba85be316b9eb88a36d81f2cc9baa/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 13, 2022
@philwebb
Copy link
Member

I'm not sure how easy this will be to fix. I suspect that we can't just add a property attribute to the docker @Parameter because it's a complex type. We'll need to dig into the internals of Maven.

In the meantime, you can probably do something like this:

<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration>
    <image>
      <name>${docker.image.prefix}/${project.artifactId}:${project.version}</name>
    </image>
    <docker>
      <publishRegistry>
        <username>${spring-boot.build-image.publishRegistry.username}</username>
        <password>${spring-boot.build-image.publishRegistry.password}</password>
        <url>${spring-boot.build-image.publishRegistry.url}</url>
      </publishRegistry>
    </docker>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>build-image</goal>
      </goals>
    </execution>
  </executions>
</plugin>

@philwebb philwebb added the for: team-attention An issue we'd like other members of the team to review label May 13, 2022
@snicoll
Copy link
Member

snicoll commented May 16, 2022

It's indeed not possible to map a nested parameter unless we create a parameter for the sole purpose to be mapped. This is one of the downsides of using such structure with Maven plugins. I don't think we should expose the parameters and users should rather define a property that suits their needs using either the suggestion above, or using a profile.

@scottfrederick
Copy link
Contributor

I don't think we should expose the parameters and users should rather define a property that suits their needs using either the suggestion above, or using a profile.

I agree with @snicoll, as Maven makes it simple enough to create your own properties and use them in the plugin configuration.

@wilkinsona
Copy link
Member

I too agree with @snicoll. We've already seen some examples of users defining their own properties such as this from
#29756:

<configuration>
    <image>
        <name>${docker.image-name}</name>
    </image>
    <docker>
        <publishRegistry>
            <username>${docker.credentials.username}</username>
            <password>${docker.credentials.password}</password>
        </publishRegistry>
    </docker>
</configuration>

This feels like the right way to go to me.

@philwebb philwebb changed the title Allow spring-boot:build-image to accept publishRegistry parameters over the command line Add documentation tip showing how to configure publishRegistry maven properties from the command line May 16, 2022
@philwebb
Copy link
Member

Thanks everyone. I'm going to repurpose this one as documentation issue.

@philwebb philwebb added type: documentation A documentation update and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels May 16, 2022
@philwebb philwebb added this to the 2.5.x milestone May 16, 2022
@wilkinsona wilkinsona modified the milestones: 2.5.x, 2.6.x May 19, 2022
@ffroliva

This comment was marked as resolved.

@snicoll

This comment was marked as resolved.

@scottfrederick
Copy link
Contributor

Closing in favor of #34517

@scottfrederick scottfrederick added status: superseded An issue that has been superseded by another and removed type: documentation A documentation update labels Mar 8, 2023
@scottfrederick scottfrederick removed this from the 2.7.x milestone Mar 8, 2023
@scottfrederick scottfrederick closed this as not planned Won't fix, can't repro, duplicate, stale Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
6 participants