-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
documentationA PR that adds to documentation - used by Release DrafterA PR that adds to documentation - used by Release Drafter
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):
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?
mfrattola-aru
Metadata
Metadata
Assignees
Labels
documentationA PR that adds to documentation - used by Release DrafterA PR that adds to documentation - used by Release Drafter