Skip to content

Instantly share code, notes, and snippets.

@wtrocki
Created December 19, 2016 16:54
Show Gist options
  • Select an option

  • Save wtrocki/18851e5edd47205414f1fe5c39d45ba4 to your computer and use it in GitHub Desktop.

Select an option

Save wtrocki/18851e5edd47205414f1fe5c39d45ba4 to your computer and use it in GitHub Desktop.
import hudson.security.*
// Provide username and password here
def userName = "";
def password = "";
// Do not edit script after this line
def instance = Jenkins.getInstance();
def strategy = instance.getAuthorizationStrategy();
jenkins.model.Jenkins.instance.securityRealm.createAccount(userName, password);
strategy.add(hudson.model.Item.BUILD, userName);
strategy.add(Item.CANCEL, userName);
strategy.add(Item.CONFIGURE , userName);
strategy.add(Item.CREATE , userName);
strategy.add(Item.DELETE , userName);
strategy.add(Item.DISCOVER , userName);
strategy.add(Item.READ , userName);
strategy.add(Item.WORKSPACE , userName);
instance.save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment