Skip to content

Commit d9051bd

Browse files
authored
bugfix: support MySQL up to 9.4 and PostgreSQL up to 17 [JENKINS-75858] (#928)
1 parent f77c471 commit d9051bd

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

README.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ By default, the Jenkins Pipeline Maven Plugin uses an H2 embedded database, but
535535
Configuration steps to use a MySQL:
536536

537537
* Create an empty MySQL database with a dedicated MySQL user with permissions for Data Manipulation Language actions (DML) and Data Definition Language (DDL) actions
538-
** Tested with MySQL up to 8.1, with MariaDB up to 11.1 and with Amazon Aurora MySQL 5.6
538+
** Tested with MySQL up to 9.4, with MariaDB up to 11.1 and with Amazon Aurora MySQL 5.6
539539
* Install the Jenkins `MySQL Database` plugin
540540
** Navigate to `Manage Jenkins / Manage Plugins / Available`, select the `MySQL Database` plugin and click on `Download now and install after restart`
541541
* Configure the Pipeline Maven Plugin to use the created MySQL database
@@ -564,7 +564,7 @@ By default, the Jenkins Pipeline Maven Plugin uses an H2 embedded database, but
564564
Configuration steps to use a PostgreSQL:
565565

566566
* Create an empty PostgreSQL database with a dedicated PostgreSQL user with permissions for Data Manipulation Language actions (DML) and Data Definition Language (DDL) actions
567-
** Tested with PostgreSQL up to 16
567+
** Tested with PostgreSQL up to 17
568568
* Install the Jenkins the https://plugins.jenkins.io/postgresql-api/[PostgreSQL API] plugin
569569
** Navigate to `Manage Jenkins / Manage Plugins / Available`, select the `PostgreSQL API` plugin and click on `Download now and install after restart`.
570570
* Configure the Pipeline Maven Plugin to use the created PostgreSQL database

pipeline-maven-database/src/main/java/org/jenkinsci/plugins/pipeline/maven/db/AbstractPipelineMavenPluginDao.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public FormValidation validateConfiguration(Config config) {
296296
metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion();
297297
LOGGER.log(Level.INFO, "Checking JDBC connection against " + databaseVersionDescription);
298298
String databaseRequirement =
299-
"MySQL Server up to 8.1 or Amazon Aurora MySQL 5.6+ or MariaDB up to 11.1 or PostgreSQL up to 16 is required";
299+
"MySQL Server up to 8.1 or Amazon Aurora MySQL 5.6+ or MariaDB up to 11.1 or PostgreSQL up to 17 is required";
300300
if ("MariaDB".equals(metaData.getDatabaseProductName())) {
301301
@Nullable
302302
String mariaDbVersion = PipelineMavenPluginMySqlDao.extractMariaDbVersion(
@@ -327,6 +327,9 @@ public FormValidation validateConfiguration(Config config) {
327327
metaData.getDatabaseProductVersion());
328328

329329
switch (metaData.getDatabaseMajorVersion()) {
330+
case 9:
331+
// OK
332+
break;
330333
case 8:
331334
// OK
332335
break;
@@ -380,6 +383,7 @@ public FormValidation validateConfiguration(Config config) {
380383
}
381384
}
382385
switch (metaData.getDatabaseMajorVersion()) {
386+
case 17:
383387
case 16:
384388
case 15:
385389
case 14:

pipeline-maven-database/src/test/java/org/jenkinsci/plugins/pipeline/maven/db/PipelineMavenPluginMySqlDaoIT.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
public class PipelineMavenPluginMySqlDaoIT extends PipelineMavenPluginDaoAbstractTest {
5757

5858
@Container
59-
public static MySQLContainer<?> DB = new MySQLContainer<>(MySQLContainer.NAME).withImagePullPolicy(alwaysPull());
59+
public static LatestMySQLContainer DB = new LatestMySQLContainer().withImagePullPolicy(alwaysPull());
6060

6161
@Override
6262
public DataSource before_newDataSource() {
@@ -112,4 +112,23 @@ public void ensureValidateConfiguration() throws Exception {
112112
assertThat(result.toString()).isEqualTo("OK: MySQL " + version + " is a supported database");
113113
}
114114
}
115+
116+
// Need
117+
// https://github.com/testcontainers/testcontainers-java/issues/10184
118+
// https://github.com/testcontainers/testcontainers-java/pull/10185
119+
// to be fixed
120+
static class LatestMySQLContainer extends MySQLContainer<LatestMySQLContainer> {
121+
122+
public LatestMySQLContainer() {
123+
super(MySQLContainer.NAME + ":9");
124+
}
125+
126+
protected void configure() {
127+
addEnv("MYSQL_DATABASE", getDatabaseName());
128+
addEnv("MYSQL_USER", getUsername());
129+
addEnv("MYSQL_PASSWORD", getPassword());
130+
addEnv("MYSQL_ROOT_PASSWORD", getPassword());
131+
setStartupAttempts(3);
132+
}
133+
}
115134
}

pipeline-maven-database/src/test/java/org/jenkinsci/plugins/pipeline/maven/db/PipelineMavenPluginPostgreSqlDaoIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class PipelineMavenPluginPostgreSqlDaoIT extends PipelineMavenPluginDaoAb
5757

5858
@Container
5959
public static PostgreSQLContainer<?> DB =
60-
new PostgreSQLContainer<>(PostgreSQLContainer.IMAGE).withImagePullPolicy(alwaysPull());
60+
new PostgreSQLContainer<>(PostgreSQLContainer.IMAGE + ":17").withImagePullPolicy(alwaysPull());
6161

6262
@Override
6363
public DataSource before_newDataSource() throws Exception {

0 commit comments

Comments
 (0)