Exercises
We have learned a lot about Jenkins configuration throughout this chapter. To consolidate the knowledge, we recommend two exercises on preparing the Jenkins images and testing the Jenkins environment.
- Create Jenkins master and slave Docker images and use them to run the Jenkins infrastructure capable of building the Ruby projects:
- Create the master Dockerfile, which automatically installs the Docker plugin.
- Build the master image and run the Jenkins instance
- Create the slave Dockerfile (suitable for the dynamic slave provisioning), which installs the Ruby interpreter
- Build the slave image
- Change the configuration in the Jenkins instance to use the slave image
- Create a pipeline, which runs a Ruby script printing
Hello World from Ruby
:- Create a new pipeline
- Use the following shell command to create the
hello.rb
script on the fly:sh "echo "puts 'Hello World from Ruby'" > hello.rb"
- Add the command to run
hello.rb
using the Ruby interpreter - Run the build and observe the console output