Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bmaehr opened this issue Jun 24, 2022 · 4 comments
Open

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

bmaehr opened this issue Jun 24, 2022 · 4 comments
Labels
documentation A PR that adds to documentation - used by Release Drafter

Comments

@bmaehr
Copy link

bmaehr commented Jun 24, 2022

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?

@bmaehr bmaehr added the documentation A PR that adds to documentation - used by Release Drafter label Jun 24, 2022
@bmaehr
Copy link
Author

bmaehr commented Mar 9, 2023

@basil @jetersen @timja Could someone answer this question please?

@timja
Copy link
Member

timja commented Mar 9, 2023

you can't configure a database in the pipeline itself currently, only via global configuration

@bmaehr
Copy link
Author

bmaehr commented Mar 9, 2023

Ok. Would it be possible to support the id field in the global database setup to allow multiple databases?

@timja
Copy link
Member

timja commented Mar 9, 2023

yes that would be fine if someone implemented it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation A PR that adds to documentation - used by Release Drafter
Projects
None yet
Development

No branches or pull requests

2 participants