JenkinsSecurityViaDSL

From DrewWiki
Revision as of 22:46, 30 January 2018 by Drew (talk | contribs) (added JenkinsSecurityViaDSL)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Jenkins Groovy DSL to change security to role strategy

Notes: Role strategy plugin must be installed

import jenkins.model.*
import hudson.security.*
import com.michelin.cio.hudson.plugins.rolestrategy.*
def instance = Jenkins.getInstance()
def hudsonRealm = new HudsonPrivateSecurityRealm(false)
instance.setSecurityRealm(hudsonRealm)
def strategy = new RoleBasedAuthorizationStrategy()
strategy.add(Jenkins.ADMINISTER, "admin")
instance.setAuthorizationStrategy(strategy)
instance.save()