Reading H2 database (jenkins-jobs.mv.db) for pipeline Maven plugin
In retrospective, it looks like issue was not related specifically to Jenkins database.
INstead, it was because of using groovy Sql in wrong way. This question helped in getting answer org.h2.jdbc.JdbcSQLException: The object is already closed.
Using createQueryCommand
instead of executeQuery
worked:
query = sql.createQueryCommand("SHOW TABLES")rs = query.execute()while(rs.next()) { result = rs.getString(1) println(result)}
Or in the simplest way possible:
println(sql.rows("SHOW TABLES"))