blob: 34be37ada03990b04b3046a2a9df892c78930945 [file] [log] [blame]
#!groovy
// jenkins molecule/default/molecule.yml
//
// SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
// SPDX-License-Identifier: Apache-2.0
import hudson.security.*
import jenkins.model.*
// Disable Setup Wizards
if(Jenkins.instance.getSecurityRealm().getClass().getSimpleName() == 'None') {
def instance = Jenkins.getInstance()
// Those files should be mounted into the jenkins master container
def setupUser = '{{ jenkins_admin_username }}'
def setupPass = '{{ jenkins_admin_password }}'
def hudsonRealm = new HudsonPrivateSecurityRealm(false)
instance.setSecurityRealm(hudsonRealm)
def user = instance.getSecurityRealm().createAccount(setupUser, setupPass)
user.save()
def strategy = new FullControlOnceLoggedInAuthorizationStrategy()
strategy.setAllowAnonymousRead(false)
instance.setAuthorizationStrategy(strategy)
instance.save()
println("SetupWizard Disabled")
}