Running Jenkins CI as a Service

If you’d rather install Jenkins as a proper service (i.e. not as a Docker container), you can always install jenkins the old-fashioned way.

Running Jenkins CI via Docker

On any Docker-enabled machine, you can easily start a Jenkins container by executing the following command:

docker run -it --name=jenkins -p 8080:8080 -p 50000:50000 -v /home/jenkins_home:/var/jenkins_home jenkins:2.7.2-alpine


NOTE: To start the container in the background you can use pass the -d flag as well.

The first time you run this image, Docker will download it – this can take several minutes depending on the quality of your network.
Once downloaded, Docker will create a new container (instance) from the image and start your Jenkins service within the container.

You can then start / stop the container using the following commands:

docker stop jenkins
docker start jenkins

Jenkins CI “First Run" Setup

Once the , you should be able to navigate to http://ip-or-localhost:8080 in your browser to reach the Jenkins UI.
Jenkins will prompt you for an administrator password on first boot, which can be found by reading its logs:

docker logs jenkins

 

After retrieving the password and logging in, you will be asked to set up additional use and choose which plugins to install.

For example:

Testing Jenkins CI with GitHub Integration

After the plugins finish installing and Jenkins is ready, you should be dropped on the Dashboard and given a link to create a new job:

  1. Create a new job
  2. Set SCM type to “Git” and point at the Git repository containing the code you would like to build
  3. Add any build steps you want to execute – as a simple test, you can choose “Execute shell” to execute the “ls –al” command
  4. Click Apply/Save, then build the new job – you should see your new build job appear in the queue on the left
  5. Click the new build to view details about it and click “Console Output” to watch the console output your build
  • No labels