21 lines
695 B
Groovy
21 lines
695 B
Groovy
import jenkins.model.*
|
|
import hudson.security.*
|
|
|
|
def instance = Jenkins.getInstance()
|
|
|
|
// ユーザー名とパスワードを設定
|
|
def adminUsername = System.getenv("JENKINS_USER") ?: "admin"
|
|
def adminPassword = System.getenv("JENKINS_PASS") ?: "password"
|
|
|
|
// セキュリティ設定を行い、管理者アカウントを作成
|
|
def hudsonRealm = new HudsonPrivateSecurityRealm(false)
|
|
hudsonRealm.createAccount(adminUsername, adminPassword)
|
|
instance.setSecurityRealm(hudsonRealm)
|
|
|
|
// 全ユーザーにアクセス権を付与
|
|
def strategy = new FullControlOnceLoggedInAuthorizationStrategy()
|
|
strategy.setAllowAnonymousRead(false)
|
|
instance.setAuthorizationStrategy(strategy)
|
|
|
|
instance.save()
|