Managing Minecraft with Jenkins
Submitted By Jenkins User Richard Staehler III
Cutting costs by providing the kids with a way to play Minecraft in the cloud without getting a huge cloud bill from Google. All thanks to Jenkins.
Organization: This is a personal project for a gaming family!
Industry: Personal project
Programming Language: Groovy
Platform: Linux, GCP
Version Control System: GitHub
Build Tool: gCloud, Jenkins
Building the kids a self-serve Minecraft setup using Jenkins.
Background: I wanted to provide my kids a way to play Minecraft in the cloud but not cost a fortune. Jenkins allows my kids to turn on Minecraft with a simple webhook and pipelines, and allows me to keep my pocketbook closed to the Google Cloud gods.
Goal: The ultimate goal was to maintain pipelines that my family could easily kick off to spin up our personal Minecraft server running on GCP. The Minecraft instance is preemptive so it shuts off when not in use.
Solution & Results: After I had a working model, I wanted to automate it. I also wanted to set the compute to be preemptive so I don’t have a run-away bill but I also didn’t want to log into GCP each time to start it.
That being said, I leveraged Jenkins to turn on the instance (if offline), mount the drive, and start the service. Furthermore, I have additional pipelines to stop the instance (if desired), pull the status of the compute, and even upgrade Minecraft if it’s out of date.
After setting all this automation up, I realized that my kids would have to log into Jenkins, so I set up webhooks with Discord and Slack and even created a little batch file so they can easily start it wherever they are at.
To meet these challenges, I created a handful of pipelines to do the job: one to start the instance, one to stop the instance, one to obtain the status of the server, and one to upgrade Minecraft. These pipelines use shared methods and libraries and are primarily driven by gcloud commands.
All of the Jenkins Groovy code is stored in GitHub. There is obviously an option to store the code inside the pipeline itself, but I’ve been burned too much by systems failing or upgrades breaking things. Now that this is mature and the kids know how to operate it, I’ll be moving to the next phase and will set up the infrastructure utilizing Terraform and Jenkins to orchestrate.
Here are the key capabilities I used:
- Jenkins (latest version)
- Discord Notifier
- Email Extension Plugin
- GitHub Plugin
- Various GCP Plugins
- Green Balls
- Pipeline Utility Steps
- Role-based Authorization Strategy
- Simple Theme Plugin
- Slack Notification Plugin
Jenkins is an amazing tool. I use it day-to-day where I work and also used it at previous jobs. I know its potential and ease of use especially when it comes to either building standalone jobs or multi-branch pipelines utilizing Groovy. I have yet to find a tool that can do what Jenkins can do! And the results speak for themselves:
- cloud compute can stay offline when not in use
- end-users can turn on without having to log into GCP or Jenkins
- checks are in place for all the different scenarios