Skip to content

Instantly share code, notes, and snippets.

@jsrois
Last active May 12, 2016 14:37
Show Gist options
  • Save jsrois/fb57dd4f743306a93fbdfd984fb43c15 to your computer and use it in GitHub Desktop.
Save jsrois/fb57dd4f743306a93fbdfd984fb43c15 to your computer and use it in GitHub Desktop.
#!/bin/bash
domain_name=example.com
date_info=$(date +%s)
output_file=add_users_$date_info.groovy
echo "// Automatically generated groovy script -- $date_info" > $output_file
while [[ $# > 0 ]]
do
echo "generating user/password for [$1]..."
pass=$(date +%s | sha256sum | base64 | head -c 32 ; echo)
user=$1
email=$user@$domain_name
cat <<EOT >> $output_file
jenkins.model.Jenkins.instance.securityRealm.createAccount("$user", "$pass")
def user = hudson.model.User.get("$user");
def userEmail = "$email";
user.addProperty(new hudson.tasks.Mailer.UserProperty(userEmail));
EOT
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment