How To: Update Passwords with a Groovy Script
If you currently use the Datical GUI to manually change your passwords, we have provided a sample script and associated input file that can be used for updating passwords using a CSV file. The following two files are required:
updateDBPasswords.groovy (download here)
changePasswords.csv (download here)
updateDBPasswords.groovy
This file should be housed in the <datical_installation_dir>\repl\scripts folder.
There are two parameters that should be modified within this file:
daticalBaseDir - the parent directory where all Datical DB projects are housed. Be sure to use a Windows path for this directory, eg.
def daticalBaseDir = "C:\\Users\\AmySmith\\datical\\"
passwordFile - set to changePasswords.csv but can be adjusted if you wish to rename this file. This password file should be placed in the daticalBaseDir specified above.
def passwordFile = "passwordList.csv"
changePasswords.csv
To use the updateDBPasswords.groovy, Liquibase administrators must supply the information in the following format in a changePasswords.csv file: project, dbDef, password
project - the name of the folder housing the DDB project. If projects are housed within subfolders from the daticalBaseDir, include the subfolder in the path. In this case use a '/' as the separator.
dbDef - the name of the dbDef as specified in the datical.project
password - the password for the dbDef. This password should be added in clear text. It is important to keep this file secure and not check the file into source control.
Sample changePasswords.csv content
project,dbDef,password
ET/ET_ORACLE_DDB,REF1,liquibase_user
GAMBIT_DDB,REF5,changeme
GAMBIT_DDB,PROD,changeme
Process Overview and Instructions
Place the updatedDBPasswords.groovy in the <datical_install_dir>/repl/scripts folder.
Update the daticalBaseDir variable to point to the parent directory where all Datical DB projects are housed.
Populate the changePasswords.csv and place in the parent directory where all Datical DB projects are housed (the same value that was set as daticalBaseDir.)
From the same directory where you added the changePasswords.csv file, run the following command:
The process performs the following for each row in the changePasswords.csv file:
Runs a
git status
andgit pull
in the project’s directory.Base64 encodes the password value.
Checks the datical.project file in the project’s directory for the dbDef.
Replaces the old password string with the new base64 encoded password.
Runs a
git add datical.project
,git commit -m'<Message>'
, and agit push
.
Troubleshooting
If the daticalBaseDir or the project cannot be found, the following example error is thrown:
Error executing Groovy script. C:\Users\AmySmith\datical\ET\ET_ORACLE_DDB\datical.project (The system cannot find the path specified)
For missing project, dbDef, or password values the following example errors are thrown:
A project value was not found. Skipping row 3.
A dbDef value not supplied for ET/ET_ORACLE_DDB. Skipping row 2.
Password value not supplied for ET/ET_ORACLE_DDB and REF1. Skipping row 2.
If the dbDef cannot be found in the project, the following example error is thrown:
DbDef REF10 was not found in the datical.project for ET/ET_ORACLE_DDB.
If a change has not been detected for an existing dbDef password, the following example error is thrown:
No changes detected for the password to REF1 in project ET/ET_ORACLE_DDB
Copyright © Datical 2012-2020 - Proprietary and Confidential