Skip to content

Instantly share code, notes, and snippets.

@marcosborges
Last active April 6, 2019 01:39
Show Gist options
  • Save marcosborges/c3ddc002d4a68312c7007a7144a3f603 to your computer and use it in GitHub Desktop.
Save marcosborges/c3ddc002d4a68312c7007a7144a3f603 to your computer and use it in GitHub Desktop.
def _provisioningMysqlUser(host, master_username, master_password, new_username, new_username_password) {
docker.image('mysql:5').inside(" --net=host ") {
def sqlCreateUser = "CREATE USER '${new_username}'@'%' IDENTIFIED BY '${new_username_password}';"
sh """ mysql -h ${host} -u ${master_username} --password="${master_password}" -e "${sqlCreateUser}" """
def sqlGrantAllPriv = "GRANT ALL PRIVILEGES ON *.* TO '${new_username}'@'%';"
sh """ mysql -h ${host} -u ${master_username} --password="${master_password}" -e "${sqlGrantAllPriv}" """
}
}
node{
_provisioningMysqlUser(
"127.0.0.1",
"root",
"root",
"new_username",
"new_username_password"
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment