Customized jenkins image build Dockerfile that lets you build a Jenkins docker image with (but not limited to) the following use cases:
- Disable Jenkins Install Setup Wizard (JAVA_OPTS "-Djenkins.install.runSetupWizard=false"), and install the suggested plugins as seen by the setup wizard
- Install a list of useful plugins, examples: periodicbackup, monitoring (JavaMelody), green-ball button,...
- Groovy init scripts to be placed in reference (/usr/share/jenkins/ref/init.groovy.d) folder and later be copied to $JENKINS_HOME/init.grooy.d to:
- 3.1 create first admin user account
- 3.2 set baseURL
- 3.3 enable agent to master access control
- 3.4 set number of executors
- The build script makes use of bash shell functions to download/install awscli v2 (in container), and terraform binary so as to be copied to jenkins docker image
- The jenkins docker image also includes typical tools including curl, git, jq, maven, tree, wget, zip, python3, pip3, ansible 2.9.10, jinja2, dnspython
- "git clone https://github.com/garyttt/unattended_jenkins_image_build.git jenkins" using an account with uidNumber=1000 (jenkins)
- cd jenkins/
- edit all .sh scripts, replace 'REPO=garyttt8' (my Docker Hub account) with your Docker Hub account 'REPO=yourdockerhubaccount'
- edit 01_set_baseURL.groovy, replace hostname in 'location.url' with your actual docker hostname
- ./jenkins_image_build.sh TAG --progress=plain where TAG is the docker image tag you so desired, I tend to tally it with the "FROM jenkins/jenkins:TAG" in dockerfile, example: TAG is 2.449-jdk17
- go for a 30-min or so coffee break, preferably you rebuild during non-peak/lunch hour
- you may inspect the docker_build.log post build for errors, note that warnings could usaully be ignored
- ./jenkins_run.sh TAG where TAG is the docker tag you have assigned to jenkins image, it is actually restarting jenkins, i.e. it calls ./jenkins_stop.sh first
- docker run log file will be fetched continuously, you may Ctrl-C to break it
- http://hostname:8080 (HTTP) or http://hostname:8080/jenkins if "--prefix=/jenkins is set in 'env JENKINS_OPTS'" in dockerfile, https://hostname:8083 (HTTPS) or http://hostname:8083/jenkins if "--prefix=/jenkins is set in 'env JENKINS_OPTS'" in dockerfile. Please note it would take at least few minutes for browser to fully launch jenkins. Replace hostname with actual docker hostname, please change admin password ASAP
- refer to 'Jenkins_Period_Backup_Config_Example.pdf' to quickly configure it, do not forget to validate cron syntax and existence of backup folder
- take a on-demand config backup whenever you have made changes and note down the timestamp (drop list of recent timestamps is shown when you click 'restore')
- if you even re-build the image and need the previous config. perform a restore
- first run 'generate_self_signed_jks.sh', then un-comment the related lines in dockerfile, re-build the image, as well as copy/paste the right lines in jenkins_run.sh, re-run to test
- You may automate these groovy scripts using JCasC Jenkins Configuration As Code plugin