jenkinsci / jenkinsci/database-plugin

Please improve the documentation how to use a non global database

Open
#129 4 comments 1 reaction 0 assignees View on GitHub
documentation
Dominant language
Java
Stars
8
Forks
18
Avg merge
16m
Merged PRs (30d)
4

Description

### 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):

```groovy
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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.