Skip to content

Instantly share code, notes, and snippets.

@simplytunde
Created August 24, 2017 07:00
Show Gist options
  • Save simplytunde/e1e274564ad4c94ea2ce9d5a10ec3f7b to your computer and use it in GitHub Desktop.
Save simplytunde/e1e274564ad4c94ea2ce9d5a10ec3f7b to your computer and use it in GitHub Desktop.
Automated Jenkins
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
#!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