Deploy Hugo Sites With Jenkins

I’ll describe how I do my Hugo-based blog updates with Jenkins, but it’s pretty similar to any other static site generator.

Pre-requirements

Jenkins installation is out of the scope of this post. Also, you need to have installed and configured Publish Over SSH plugin.

Also, I use Jenkins Job Builder (JJB) to configure Jenkins jobs from yaml file.

I’ll describe my blog-jobs.yaml config for my blog below.

Jenkins configuration

Views

If you have a lot of jobs or just want to group them by project, it makes sense to create a view:

- view:
    name: Blog
    view-type: list
    job-name:
      - build-blog
      - build-blog-theme

Since I’ve got own blog theme, I need to track theme changes too.

SCM

It’s pretty simple here:

- scm:
    name: blog-github
    scm:
      - git:
         url: https://github.com/e0ne/blog.e0ne.info.git
         branches:
          - origin/master

- scm:
    name: e0ne-hugo
    scm:
      - git:
         url: https://github.com/e0ne/e0ne-hugo.git
         branches:
          - origin/master

Job templates

Simple template for theme:

- job-template:
    name: 'build-blog-theme'
    id: 'build-blog-theme'
    branch: master
    scm:
      - e0ne-hugo
    builders:
      - shell: |
         hugo version

    publishers:
      - trigger:
          project: build-blog

Do not forget to trigger blog update job here.

Build a blog from sources:

- job-template:
    disabled_var:
    test_var: Hello World
    name: 'build-blog'
    id: 'build-blog'
    disabled: '{obj:disabled_var}'
    branch: master
    scm:
      - blog-github
    builders:
      - shell: |
         git clone http://github.com/e0ne/e0ne-hugo.git themes/e0ne-hugo
         hugo
    triggers:
      - pollscm:
          cron: "@hourly"
    publishers:
      - ssh:
          site: 'blog.e0ne.info'
          target: 'html'
          clean-remote: true
          source: 'public/**/*.*'
          timeout: 1800000
          use-pty: true
          always-publish-from-master: true
          fail-on-error: true
          verbose: true

Jobs definition

Jobs templates step is optional for such a simple project, but I prefer to keep with consistency with others. Now I need to define jobs and run JBB to update my Jenkins configuration.

- project:
    name: blog
    jobs:
        - 'build-blog':
        - 'build-blog-theme':

That’s all:). I hope it will be useful for sombody.

Tags

.net .net-framework .net-framework-3.5 agile ajax ajax-control-toolkit ampq ansible apache asp.net asp.net-mvc automation axum babel bash benchmark blog blog-engine bootstrap buildout c# cache centos chrome ci cinder ckan cli cloud code-review codeplex community config debugger deface dependencies development-environment devices devstack devtime disks django dlr dns docker dockerimage dos easy_install elmah encoding environment-variables error event events everything-as-a-code exception exceptions fabrik firefox flask foreach forms fstab gae gcc gerrit git github go google google-app-engine grep hack hacked hardware headless horizon hound html hugo iaas ienumerable iis internet iptables iron-python ironic iscsi java-script javascript jenkins jquery js jsx k8s kharkivpy kiss kombu kubernetes kvm kyiv lettuce libvirt linux lio loci logging loopback losetup lvm mac-os macos mercurial microsoft microsoft-sync-framework mobile mono ms-office msbuild networking news nginx npm npx offtopic oop open-source open-xml opensource openstack openvswitch os packages paraller-development patterns-practices performance php pika pip plugins pnp podcast popup postgresql profiler project protocols proxy pycamp pycharm pycon pykyiv pylint pypi python python-3 qcow quantum qumy rabbitmq rar react reactjs refactoring rfc rhel search-engine security selenium server shell silverlight socket software-engineering source-control sourcegear-vault sources sql sql-server sql-server-express sqlalchemy ssh static-site sublimetext svg tests tgt tipfy todo tornado typescript uapycon ui uneta unit-tests upgrades usability vim virtualenv visual-studio vitrage vm vue.js vuejs web-development web-server web-service web_root webpack webroot windows windows-live word-press x32 x64 xcode xml xss xvfb интернет-магазин книги

Recent posts

Go 1.18: new features

Всё будет Kubernetes

2022 Relaunch

Everyday Blogging

I don't want this CI


Archives

2022 (3)
2019 (73)
2018 (2)
2017 (3)
2016 (2)
2015 (3)
2014 (5)
2013 (17)
2012 (22)
2011 (36)
2010 (25)
2009 (35)
2008 (32)
2007 (2)