I have three scripts that create table1, table2, and table3. I need to deploy these in different environments, and for this purpose, I am creating a Jenkins pipeline to execute my SQL scripts.
During the first run, all scripts are executed successfully and the tables are created. However, in subsequent runs, Oracle is giving an error message: “object already exists,” which is displayed in the deployment log file.
How can we capture this validation/error message so that we can update the build status based on it?
Any suggestions would be appreciated.
pipeline {
agent any
stages {
stage('Run SQL Scripts') {
steps {
script {
def scripts = ['script1.sql', 'script2.sql', 'script3.sql']
for (script in scripts) {
step([$class: 'SQLRunnerBuilder',
credentialsId: 'your-credentials-id',
instance: 'your-instance',
scriptType: 'file',
script: script])
}
}
}
}
}
}