Hung-Wei Chiu | 80dc18d | 2020-10-20 23:56:46 +0000 | [diff] [blame^] | 1 | #!groovy |
| 2 | // jenkins molecule/default/molecule.yml |
| 3 | // |
| 4 | // SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org> |
| 5 | // SPDX-License-Identifier: Apache-2.0 |
| 6 | |
| 7 | |
| 8 | import hudson.security.* |
| 9 | import jenkins.model.* |
| 10 | |
| 11 | // Disable Setup Wizards |
| 12 | if(Jenkins.instance.getSecurityRealm().getClass().getSimpleName() == 'None') { |
| 13 | def instance = Jenkins.getInstance() |
| 14 | |
| 15 | // Those files should be mounted into the jenkins master container |
| 16 | def setupUser = '{{ jenkins_admin_username }}' |
| 17 | def setupPass = '{{ jenkins_admin_password }}' |
| 18 | |
| 19 | def hudsonRealm = new HudsonPrivateSecurityRealm(false) |
| 20 | instance.setSecurityRealm(hudsonRealm) |
| 21 | def user = instance.getSecurityRealm().createAccount(setupUser, setupPass) |
| 22 | user.save() |
| 23 | |
| 24 | def strategy = new FullControlOnceLoggedInAuthorizationStrategy() |
| 25 | strategy.setAllowAnonymousRead(false) |
| 26 | instance.setAuthorizationStrategy(strategy) |
| 27 | |
| 28 | instance.save() |
| 29 | |
| 30 | println("SetupWizard Disabled") |
| 31 | } |