Created
April 16, 2020 00:45
-
-
Save dalmosantos/261708d21f4bf3412a3e5d6f46c5699a to your computer and use it in GitHub Desktop.
Jenkins Docker
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/jenkins:lts-slim | |
| USER root | |
| # install docker | |
| RUN mkdir -p /usr/share/man/man1 && \ | |
| apt-get update ; apt-get upgrade -y && \ | |
| apt-get install --no-install-recommends -y cpio rpm2cpio zip unzip vim-tiny maven sshpass git && \ | |
| apt-get clean autoclean && \ | |
| apt-get autoremove -y && \ | |
| rm -rf /var/lib/{apt,dpkg,cache,log} /tmp/* | |
| USER jenkins | |
| ENV SECRETS_DIR=/run/secrets \ | |
| # Whether to skip setup wizard | |
| JAVA_OPTS="-Djenkins.install.runSetupWizard=false" | |
| # Creates username and password specified through environment variables JENKINS_USER_SECRET and JENKINS_PASS_SECRET | |
| COPY security.groovy /usr/share/jenkins/ref/init.groovy.d/security.groovy | |
| # Setting the number of executors | |
| #COPY executors.groovy /usr/share/jenkins/ref/init.groovy.d/executors.groovy | |
| # Install groovy global libraries for pipeline plugin | |
| #COPY var/jenkins_home/org.jenkinsci.plugins.workflow.libs.GlobalLibraries.xml /usr/share/jenkins/ref/org.jenkinsci.plugins.workflow.libs.GlobalLibraries.xml | |
| # Install a list of plugins from the file 'plugins.txt' and their dependencies | |
| COPY 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
| ace-editor | |
| ant | |
| ansible | |
| authentication-tokens | |
| authorize-project | |
| backup | |
| beer | |
| blueocean | |
| bouncycastle-api | |
| branch-api | |
| build-timeout | |
| build-timestamp | |
| chucknorris | |
| cloudbees-folder | |
| command-launcher:1.4 | |
| configuration-as-code | |
| configuration-as-code-support | |
| credentials | |
| credentials-binding | |
| dashboard-view | |
| display-url-api | |
| docker-plugin | |
| docker-commons | |
| docker-workflow | |
| durable-task | |
| email-ext | |
| external-monitor-job | |
| filesystem_scm | |
| git-changelog | |
| git | |
| greenballs | |
| groovy | |
| icon-shim | |
| jackson2-api | |
| jdk-tool | |
| jira | |
| job-restrictions | |
| kubernetes | |
| ldap | |
| locale | |
| lockable-resources | |
| mailer | |
| mapdb-api | |
| mask-passwords | |
| matrix-auth | |
| matrix-project | |
| maven-plugin | |
| metrics | |
| monitoring | |
| ownership | |
| pam-auth | |
| pipeline-build-step | |
| pipeline-graph-analysis | |
| pipeline-input-step | |
| pipeline-milestone-step | |
| pipeline-model-api | |
| pipeline-model-declarative-agent | |
| pipeline-model-definition | |
| pipeline-model-extensions | |
| pipeline-rest-api | |
| pipeline-stage-step | |
| pipeline-stage-tags-metadata | |
| pipeline-stage-view | |
| pipeline-utility-steps | |
| publish-over-cifs | |
| rebuild | |
| role-strategy | |
| scm-api | |
| script-security | |
| security-inspector | |
| schedule-build | |
| ssh-credentials | |
| ssh-slaves | |
| timestamper | |
| token-macro | |
| windows-slaves:1.6 | |
| workflow-aggregator | |
| workflow-api | |
| workflow-basic-steps | |
| workflow-cps-global-lib | |
| workflow-cps | |
| workflow-durable-task-step | |
| workflow-job | |
| workflow-multibranch | |
| workflow-scm-step | |
| workflow-step-api | |
| workflow-support | |
| ws-cleanup | |
| xray-connector |
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(System.getenv()["SECRETS_DIR"] + "/jenkins-user").text.trim() | |
| def pass = new File(System.getenv()["SECRETS_DIR"] + "/jenkins-pass").text.trim() | |
| println "Creating user " + user + "..." | |
| 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) | |
| println "User " + user + " was created" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment