mardi 18 septembre 2018

Use @ActiveProfiles together with SPRING_PROFILES_ACTIVE

In my Spring Boot application I have tree profiles: the default profile, a test profile and a continuous integration profile.

The continuous integration profile define an alternative datasource.url.

The test profile define an alternative liquibase.change-log.

The default profile define default properties for my application.

When I run tests locally I run them using IntellIJ

enter image description here

and to active the test profile locally I have added the @ActiveProfiles("test") annotation to my tests.

and when I run them from my CI I have add the SPRING_PROFILES_ACTIVE env var like this:

SPRING_PROFILES_ACTIVE=ci,test gradle integrationTest 

but the ci profile is ignored by Spring Boot.

If I remove the @ActiveProfiles("test") annotation my CI work perfectly but then I can not easily run my tests using IntelliJ.

Aucun commentaire:

Enregistrer un commentaire