Pre-requisite Software

Setup Pipeline

You login to your Jenkins server. Create a new item, name it, and select Pipeline type.

[ Jenkins -> New Item -> Pipeline & Name -> OK]

You now find yourself on the configuration page.

You tick the Discard old builds checkbox, to preserve disk space as your current environment has up to 20GB. You also select 30 days to keep builds, and up to 100 builds to keep.

You tick the Do not allow concurrent builds to maintain good server performance.

You tick the Pipeline speed/durability/override checkbox, and select the Performance-optimized custom pipeline level for fast builds.

You tick the GitHub hook trigger for GITScm polling checkbox. Thus you enable the webhook feature.

You select Pipeline script from SCM, to instruct Jenkins to retrieve the Jenkinsfile from the source control.

You select Git as SCM, add the repository URL, and select credentials giving jenkins access to this repo.

You finally click Save button to complete the configuration.

The Nightmare

Creating the Jenkinsfile to work with jekyll Docker image turned out to be a nightmare.

Jenkins uses the jenkin user, but the docker image uses jekyll user. Which is a problem because the jekyll user does not have permission to write to the Jenkins workspace. Meaning you cannot use the jekyll gem to build the site.

You manage to solve this problem by changing the ownership of the site in the working space to jekyll.

In order to be able to change the ownership you instruct docker to use the root user. Normally docker image uses root by default, however jekyll/minimal uses jekyll user instead.

After jekyll builds the site, you change the ownership of the site back to jenkins:www-data.