Reputation: 826
I have an app where I want to push to repository A
or B
depending on the profile that is being run.
For instance:
If I run this in Jenkins sh "./mvnw package -Pint verify -DskipTests jib:dockerBuild"
it should push to our integration registry.
If I run this in Jenkins sh "./mvnw package -Pprod verify -DskipTests jib:dockerBuild"
it should push to our production repository.
I've set up my pom like this:
<from>
<image>adoptopenjdk:11-jre-hotspot</image>
</from>
<to>
<image>${docker.repository.url}/${docker.image.prefix}/${project.artifactId}</image>
<tags>
<tag>${project.version}-${spring.profiles.active}-${git.commit.id.abbrev}</tag>
</tags>
</to>
How do I get it to behave in this particular way?
Upvotes: 1
Views: 1269
Reputation: 29887
That's easy :D. You only need to define a <properties>
section inside the <profile>
section. These properties will be added when you run the specified profile (and I have the strong feeling it does override any property set in the global <properties>
section).
For example:
<profiles>
<profile>
<id>int</id>
<properties>
<docker.repository.url>https://your.docker.registry</docker.repository.url>
</properties>
</profile>
</profiles>
There is a bit more information on the profiles documentation page, in particular which elements can be used inside a profile.
Upvotes: 3