Created
October 10, 2017 11:02
-
-
Save asaphe/df2e1e8fc1fb6eeb067c63fb9de770e1 to your computer and use it in GitHub Desktop.
create a user for Jenkins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jenkins.model.* | |
import hudson.security.* | |
def env = System.getenv() | |
def jenkins = Jenkins.getInstance() | |
jenkins.setSecurityRealm(new HudsonPrivateSecurityRealm(false)) | |
jenkins.setAuthorizationStrategy(new GlobalMatrixAuthorizationStrategy()) | |
def user = jenkins.getSecurityRealm().createAccount(env.JENKINS_USER, env.JENKINS_PASS) | |
user.save() | |
jenkins.getAuthorizationStrategy().add(Jenkins.ADMINISTER, env.JENKINS_USER) | |
jenkins.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment