Created
August 24, 2017 07:00
-
-
Save simplytunde/e1e274564ad4c94ea2ce9d5a10ec3f7b to your computer and use it in GitHub Desktop.
Automated Jenkins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM jenkins:alpine | |
ENV JAVA_OPTS="-Djenkins.install.runSetupWizard=false" | |
COPY scripts/security.groovy /usr/share/jenkins/ref/init.groovy.d/security.groovy | |
COPY files/plugins.txt /usr/share/jenkins/ref/plugins.txt | |
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!groovy | |
import jenkins.model.* | |
import hudson.security.* | |
import jenkins.security.s2m.AdminWhitelistRule | |
def instance = Jenkins.getInstance() | |
def user = new File("/run/secrets/jenkins-user").text.trim() | |
def pass = new File("/run/secrets/jenkins-pass").text.trim() | |
def hudsonRealm = new HudsonPrivateSecurityRealm(false) | |
hudsonRealm.createAccount(user, pass) | |
instance.setSecurityRealm(hudsonRealm) | |
def strategy = new FullControlOnceLoggedInAuthorizationStrategy() | |
instance.setAuthorizationStrategy(strategy) | |
instance.save() | |
Jenkins.instance.getInjector().getInstance(AdminWhitelistRule.class).setMasterKillSwitch(false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment