Skip to content

Please improve the documentation how to use a non global database #129

@bmaehr

Description

@bmaehr

Describe your use-case which is not covered by existing documentation.

This plugin is also very helpful for end users if they want to execute SQL command in a pipeline

As example I created this pipeline script (could perhaps be added as example to the documentation):

node {
  stage('Verify') {
    getDatabaseConnection(type: "GLOBAL") {
      def resultCount = sql(sql: "SELECT count(*) FROM identifier i1, identifier i2 WHERE i1.value = i2.value AND i1.product_id < i2.product_id");
      def duplicates = resultCount.get(0).get('count');
      if (duplicates > 0) {
          if (duplicates < 201) {
            echo "Found ${duplicates} duplicates:";
            def duplicateIds = sql(sql: "SELECT i1.product_id id FROM identifier i1, identifier i2 WHERE i1.value = i2.value AND i1.product_id < i2.product_id");
            for(duplicateId in duplicateIds) {
                def id = duplicateId.get('id');
                echo "${id}";
            }
          }
          error "Found ${duplicates} duplicates ...";
      }
    }
  }
}

But this only works if I configure a database in Jenkins / Configure system

I was not able to find an example how to configure the database in the pipeline or in a stage of the script.

EDIT: Yes, I have seen the "This plugin is not meant to be used by end users by itself" but why not make a plugin helpful for many users?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationA PR that adds to documentation - used by Release Drafter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions