liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
197 stars 57 forks source link

Use hub Api key in Spring boot #88

Closed trixobird closed 2 years ago

trixobird commented 3 years ago

Hi,

I have managed to register my changelog to liquibase hub. That was done manually with pure liquibase commands. Now whenever my spring boot application start there is this warning: WARNING: The changelog ID 'f23c8811-b290-4452-ac1e-f805742fe6e8' was found, but no API Key exists. No operations will be reported. Simply add a liquibase.hub.apiKey setting to generate free deployment reports.

Is there a way to pass the hub api key? here is my build gradle:

plugins {
    id "io.spring.dependency-management" version "${springDependencyManagmentVersion}"
    id 'java'
    id 'org.liquibase.gradle' version '2.0.4'
}

sourceCompatibility = '11'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

dependencies {
    implementation platform(project(':cardmarket-platform')),
            project(':login-api'),
            'org.springframework.boot:spring-boot-starter-data-jpa'

    liquibaseRuntime 'javax.xml.bind:jaxb-api:2.3.1',
            'org.postgresql:postgresql:42.2.19',
            'org.liquibase:liquibase-core:4.3.2',
            'org.liquibase.ext:liquibase-hibernate5:4.0.0',
            sourceSets.main.output,
            sourceSets.main.runtimeClasspath

    annotationProcessor platform(project(':cardmarket-platform')),
            'org.projectlombok:lombok'

    compileOnly 'org.projectlombok:lombok'

    runtimeOnly 'org.postgresql:postgresql',
            'org.liquibase:liquibase-core'
}

liquibase {
    diff.dependsOn assemble
    diffChangeLog.dependsOn assemble

    def props = new Properties()
    file("src/main/resources/liquibase.properties").withInputStream { props.load(it) }

    activities {
        diff {
            changeLogFile props.getProperty("liquibase.changelog.diff")
            url props.getProperty("url")
            username props.getProperty("username")
            password props.getProperty("password")
            referenceDriver props.getProperty("referenceDriver")
            referenceUrl props.getProperty("liquibase.changelog.referenceUrl")
            hubApiKey props.getProperty("liquibase.hub.ApiKey")
        }
    }
    runList = 'diff'
}

test {
    useJUnitPlatform()
}

My gradle diffChangelog works fine so my setup works, at least for this specific functionality.

stevesaliman commented 3 years ago

I haven't worked with the Liquibase Hub, but Gradle is not involved when Spring Boot starts. My hunch is that the api key would need to be in the application.yml file for Spring Boot - if the Spring Boot Liquibase code supports it.

stevesaliman commented 2 years ago

Closing since the Gradle plugin isn't used when Spring Boot starts.