Jenkins installation

Jenkins is a very powerful tool and easy to learn. In this section, we are going to prepare the environment, which consists of a virtual machine running a Docker image of Jenkins. This setup is for demonstration purposes; for real scenarios, it will be better to install it in a dedicated server with more resources, or get it as a service from a company like CloudBees. In this particular case, all the configuration is located in the Vagrantfile:

Vagrant.configure("2") do |config|

config.vm.box = "ubuntu/trusty64"
config.vm.box_check_update = false

config.vm.network "forwarded_port", guest: 8080, host: 9090

config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = 2048
end

config.vm.provision "docker" do |d|
d.run "jenkins/jenkins",
args: "-p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home"
end
end

So, to get it up and running, we just need to execute the following command:

$> vagrant up
If, after a restart or whatever the reason might be, Jenkins appears offline or you can't reach it, try running the same command with provision flag:
$> vagrant up --provision

Once finished, we can open http://localhost:9090 in our favorite browser to continue the setup:

Since we are not installing it in the server but running it in a Docker image, this password is a bit tricky to get. Probably the easiest way is to access the Docker machine and get the password from the file, and that could be done like this:

$> vagrant ssh
$> docker exec jenkins-jenkins cat /var/jenkins_home/secrets/initialAdminPassword

Copy the password, paste in the password field, and we move to the next step, which is configuring plugins. For now, we are going to install the recommended ones only. Other plugins can be installed later on in the administration panel:

Then, when the setup has finished installing plugins, another screen is shown. This is the last step of the configuration, creating an admin user. It's recommended to create a user with a password that is easy to remember:

This step can be skipped, but then the admin password will remain the same as the initial password, which is really difficult to remember. Now we are ready to use our brand new Jenkins installation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.17.18