Skip to content

Commit

Permalink
Move jdbc daos classes to a separate plugin and make using H2 really …
Browse files Browse the repository at this point in the history
…optional now (Please refer to documentation when upgrading if you were using some jdbc storage) (#692)

* Move jdbc daos classes to a separate plugin

Signed-off-by: Olivier Lamy <[email protected]>

* better module name

Signed-off-by: Olivier Lamy <[email protected]>

* make dao more dynamic

Signed-off-by: Olivier Lamy <[email protected]>

* remove duplicated dependency

Signed-off-by: Olivier Lamy <[email protected]>

* fix some javadoc link

Signed-off-by: Olivier Lamy <[email protected]>

* fix Extension lookup of the dao

Signed-off-by: Olivier Lamy <[email protected]>

* fix test by using H2 to record datas

Signed-off-by: Olivier Lamy <[email protected]>

* merge master

* fix test

Signed-off-by: Olivier Lamy <[email protected]>

* this one need to be an hpi

Signed-off-by: Olivier Lamy <[email protected]>

* fix test issue with default h2

Signed-off-by: Olivier Lamy <[email protected]>

* pipeline-maven-api needs to be a plugin for classloader and displaying all extensions of dao, move sql files in correct places as loaded by the database plugin

Signed-off-by: Olivier Lamy <[email protected]>

* cleanup some code, make dynamic dao change really working

Signed-off-by: Olivier Lamy <[email protected]>

* use lookupSingleton

Signed-off-by: Olivier Lamy <[email protected]>

* add some documentation of database/dao choice

Signed-off-by: Olivier Lamy <[email protected]>

* fix images

Signed-off-by: Olivier Lamy <[email protected]>

* fix connection validation and dao creation in separate place

Signed-off-by: Olivier Lamy <[email protected]>

* cannot use this with id null

Signed-off-by: Olivier Lamy <[email protected]>

* fix dao init

Signed-off-by: Olivier Lamy <[email protected]>

* use different h2 url for test

Signed-off-by: Olivier Lamy <[email protected]>

* remove unused import

Signed-off-by: Olivier Lamy <[email protected]>

* to avoid some nit comments on extra lines added by mistake

Signed-off-by: Olivier Lamy <[email protected]>

* cleanup dependencies due to bad merge

Signed-off-by: Olivier Lamy <[email protected]>

* avoid slf4j no log warning

Signed-off-by: Olivier Lamy <[email protected]>

* i18n

Signed-off-by: Olivier Lamy <[email protected]>

* use better package, do not have same package with classes in different modules

Signed-off-by: Olivier Lamy <[email protected]>

* move jdbc test to database module

Signed-off-by: Olivier Lamy <[email protected]>

* use specific db package as well

Signed-off-by: Olivier Lamy <[email protected]>

* fix changes after ide refactoring

Signed-off-by: Olivier Lamy <[email protected]>

* use an older version for maven-core, move it  as provided as it is provided by maven distribution and such scope will avoid some security scans

Signed-off-by: Olivier Lamy <[email protected]>

* add hpi.compatibleSinceVersion property

Signed-off-by: Olivier Lamy <[email protected]>

* add note on daoClass field for CasC users

Signed-off-by: Olivier Lamy <[email protected]>

* a release has been made before this PR get merged so increase this

Signed-off-by: Olivier Lamy <[email protected]>

* improve doc per review

Signed-off-by: Olivier Lamy <[email protected]>

* add a test using yaml file can build a mysql dao

Signed-off-by: Olivier Lamy <[email protected]>

* extract the test which needs Docker apart as Testcontainers annotation is supported only at class level

Signed-off-by: Olivier Lamy <[email protected]>

* CasC test for postgres as well

Signed-off-by: Olivier Lamy <[email protected]>

* remove previous admin monitor which is useless now with the split into another plugin for the database and add an admin monitor to display error if jdbc url is configured to use a real jdbc but the pipeline-maven-database plugin is not installed

Signed-off-by: Olivier Lamy <[email protected]>

* fix copy/paste

Signed-off-by: Olivier Lamy <[email protected]>

* add license header and remove wrong author tag

Signed-off-by: Olivier Lamy <[email protected]>

* restore dao pretty print display if dao != null

Signed-off-by: Olivier Lamy <[email protected]>

---------

Signed-off-by: Olivier Lamy <[email protected]>
  • Loading branch information
olamy authored Sep 15, 2023
1 parent 36ca27d commit 333bbf0
Show file tree
Hide file tree
Showing 93 changed files with 1,030 additions and 814 deletions.
27 changes: 23 additions & 4 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ The **<<feature-default-configuration>> can be defined globally or at the folder

This plugin allows transitioning smoothly from the legacy https://plugins.jenkins.io/maven-plugin/[Maven Integration] job type by allowing to reuse **<<feature-maven-integration-global-settings>>** and by proposing the **<<feature-trigger-downstream>>**.


Please note **per default some features will not be available** and you will have to change/configure a database storage which suits your environment.

toc::[]

[#installation]
Expand All @@ -46,8 +49,8 @@ The plugin can be found under the name `Pipeline Maven Integration Plugin` in th

**For tests purposes only**, pre-releases (beta) versions are available in the https://updates.jenkins.io/#experimental-plugin-site[Experimental Plugin Site] and development versions (incremental releases) are archived on every successful build on https://ci.jenkins.io/job/Plugins/job/pipeline-maven-plugin/[our CI environment].

CAUTION: **If you use the feature <<feature-trigger-downstream>> it is critical to <<db-setup,setup a real production database>>** instead of the default embedded H2 instance.
**If you don't do it, it might degrade your environment stability** (The H2 database is running in your instance JVM and could request too many resources).
CAUTION: **If you want to use the feature <<feature-trigger-downstream>> it is critical to <<db-setup,setup a database>>** as H2 is not preconfigured by default any more.
**Using H2 might degrade your environment stability** (The H2 database is running in your instance JVM and could request too many resources).

[#changelog]
== Changelog
Expand Down Expand Up @@ -460,8 +463,8 @@ Trigger downstream pipeline that depend on Maven artifact generated by upstream
* The downstream pipeline must have selected the build trigger `Build whenever a SNAPSHOT dependency is built`
** The build trigger can be defined at the pipeline level (`Build Triggers`), at the multibranch pipeline level (`Scan Repository Triggers`) or at the GitHub Organization / Bitbucket Project level (`Scan Organizations Triggers`)
* You have to manually trigger once the upstream pipeline, and the downstream pipeline so that the link between the pipelines based on the SNAPSHOT dependency is established
* The dependency graph is, for the moment, exclusively stored in an H2 embedded database (`$JENKINS_HOME/jenkins-jobs/jenkins-jobs.mv.db`).
Support for an external H2 database and then for alternate databases (PostgreSQL) is on the roadmap (see https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.0-beta-1/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/dao/PipelineMavenPluginH2Dao.java[PipelineMavenPluginH2Dao.java])
* The dependency graph is, for the moment, optionally stored in an H2 embedded database (`$JENKINS_HOME/jenkins-jobs/jenkins-jobs.mv.db`). And there is support
for PostgreSQL and MySql as well (see details below)
====

image:docs/images/trigger-downstream-1.png[]
Expand Down Expand Up @@ -501,6 +504,22 @@ We want to quickly add reporters for CheckStyle, Jacoco...
[#db-setup]
== Database Setup

NOTE: Available since version 1332.xxxxxxxx.xxx

To use a database you must first install the `Pipeline Maven Plugin Database`

image::docs/images/pipeline-maven-plugin-database.png[]

Have a look at the Tools configuration:

image::docs/images/dao-choice.png[]

The make a choice in available DAOs options:

image::docs/images/dao-list-database.png[]

For Configuration as Code users, these are the field to add into their yaml file `daoClass` and `jdbcUrl`

[#db-setup-mysql]
=== Using a MySQL Database

Expand Down
Binary file added docs/images/dao-choice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/dao-list-database.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/pipeline-maven-plugin-database.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 17 additions & 48 deletions jenkins-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,59 +41,34 @@

<properties>
<hpi.pluginChangelogUrl>https://github.com/jenkinsci/pipeline-maven-plugin/releases</hpi.pluginChangelogUrl>
<hpi.compatibleSinceVersion>1333</hpi.compatibleSinceVersion>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.361.x</artifactId>
<version>${jenkins-tools-bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Fix RequireUpperBoundDeps dependencies -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>${plexus-utils.version}</version>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>${jansi.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>${hikaricp.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>pipeline-maven-api</artifactId>
</dependency>

<!-- move the related test to pipeline-maven-database and remove this dependency
-->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>pipeline-maven-database</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>h2-api</artifactId>
<version>${jenkins-plugin-h2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>mysql-api</artifactId>
<version>${jenkins-plugin-mysql.version}</version>
<optional>true</optional>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.google.protobuf</groupId>
Expand All @@ -105,7 +80,7 @@
<groupId>io.jenkins.plugins</groupId>
<artifactId>postgresql-api</artifactId>
<version>${jenkins-plugin-postgresql.version}</version>
<optional>true</optional>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
Expand Down Expand Up @@ -334,10 +309,8 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>test</scope>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>

<dependency>
Expand Down Expand Up @@ -455,25 +428,21 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Loading

0 comments on commit 333bbf0

Please sign in to comment.