blob: 0fb5ff6e7dd19bbab346d7ac3bc733a40bd07d49 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#!groovy
import jenkins.model.*
import hudson.security.*
def instance = Jenkins.getInstance()
def user = System.getenv()['jenkins_user']
def pass = System.getenv()['jenkins_password']
// Create user account
def hudsonRealm = new HudsonPrivateSecurityRealm(false)
hudsonRealm.createAccount(user,pass)
instance.setSecurityRealm(hudsonRealm)
// Enable matrix auth strategy and set my_user as admin
def strategy = new GlobalMatrixAuthorizationStrategy()
strategy.add(Jenkins.ADMINISTER, user)
instance.setAuthorizationStrategy(strategy)
instance.save()
|