Running Flyway migrations with Jenkins and Gradle - Unable to resolve location classpath:db/migration

Viewed 1023

When running flyway via jenkins I get the following error in the console output:

Unable to resolve location classpath:db/migration

My project source structure looks like this:

Project1
|--WEB-INF
   |--src
      |--java source
   |--flywaysrc
      |-- flyway source

My build.gradle has separate sourceSets for flyway and java:

sourceSets {
    main {
        java {          
            srcDir 'WEB-INF/src'        
        }
    }
    flyway {
        java {
            srcDir 'WEB-INF/flywaysrc'
            output.classesDir='bin'         
        }
    }
}

It also contains an entry for flyway, where locations array is set as follows:

flyway {  
    ...other configuration params...  
    ArrayList<String> locationsArray = new ArrayList<String>();  
    locationsArray.add("classpath:db/migration");  
    locationsArray.add("filesystem:/path/to/eclipse/Project1/WEB-INF/Release/old_release");
    locationsArray.add("filesystem:/path/to/eclipse/Project1/WEB-INF/flywaysrc");  
    locations=locationsArray  
    ...other configuration params...  
}

Any idea what may be causing this/what information would you need to provide more input that could help resolve this?

1 Answers

By default flyway looks for migrations in db/migrations folder in the classpath. If this db/migrations exists and it contains the migration sqls flyway will pick this up. The migration folder location can also be customised using property [locations]:(https://flywaydb.org/documentation/commandline/info)

Are you certain that you have db/migrations in the flywaysrc folder and that db/migrations contains the migration sqls?

Related