Hugo Deployments with Bitbucket Pipelines

Table of contents

These past days, I had been making a double desksurfing at Redradix to getting to know the DevOps role and trying to explain what a UI developer does, and it was very satisfying.

Desksurfing is the name of the practice in which one or multiple people are added to an external corporation during 2 or 3 days with the objective in mind to collaborate in its processes and learn about how people work, using different technologies or methodologies, making the ideas exchange easier and flowing through professionals, creating a rich experience for both sides. It is something similar to industrial spying, but regulated and profitable for both parties and without risking the life.

So, as a visitor, I was trying to understand the tasks this professional develops, professional about I did not know so much, and I learned a lot. Some of them I will forget soon because I do not do it at my normal day, but some other tasks I applied to my normal workflow and my projects, such as cotinuous integration and cotinuous deployment (CI/CD).

The problem

To develop this blog we use HUGO for so many reasons, some of them are: high performance, easy multi-language, writing post using markdown… But at the same time it is a dependency because we have to build the website when we finish an article, and we want to publish it due to Hugo generates static files, so the articles does not come from a CMS nor a database. The process is just executing a command on a terminal, but after that we have to upload the files generated manually by sftp to our server, and this is a problem.

The solution

Task automation.

So during the desksurfing I learned a little about CI/CD using Github Actions and Bitbucket’s Pipelines. So I reinforced the theory building my own CI/CD because it was such a great opportunity to avoid making mistakes when doing manually the process.

Deploy with Bitbucket

At your repository on Bitbucket there is a menu item on the side menu called ‘Deployments’. There, you could write your own pipelines to deploy or whatever task you want to automatize. It is very easy because you could choose one of the default tasks written at the configurator or write your own steps using different integrations.

Deploy after pushing to the repository

In our case, after pushing to master branch, we wanted to execute a two-step process: (1) run hugo command to build the blog and (2) upload the public folder to the server.

The code below is very self-explanatory and easy to read, but if you have any doubt feel free to comment at the bottom of the article or send to us an email to

image: atlassian/default-image:3

      - step:
          name: Build Hugo
            - apt-get update -y && apt-get install wget
            - apt-get -y install git
            - wget
            - dpkg -i hugo*.deb
            - hugo --minify
            - public/es/**
            - public/en/**
      - step:
          name: Deploy artifacts
          deployment: production
            - pipe: atlassian/sftp-deploy:0.5.8
                USER: $USER
                SERVER: $SERVER
                REMOTE_PATH: '/'
                PASSWORD: $PASSWORD
                LOCAL_PATH: 'public/es/**'
            - pipe: atlassian/sftp-deploy:0.5.8
                USER: $USER
                SERVER: $SERVER
                REMOTE_PATH: '/'
                PASSWORD: $PASSWORD
                LOCAL_PATH: 'public/en'


Sharing your work with other professionals is an incredible way to improve your level. Generating a debate through the free idea’s exchange, being open to other points of view and asking yourself about how you work and why you take one or another decision, is, by force, earn a learning. This is the reason why initiatives like desksurfing are so awesome. No matter if you are the host or the visitor or how much about a discipline you currently know, you are going to learn for sure. Sometimes the learning is not technical but related to task organization, prioritization, time management or a new.

Know more

comments powered by Disqus

If you find it interesting

If you have any doubt or you want to talk about this topic, if the content or our profiles are interesting to you and you think we could something together, do not hesitate to contact us on twitter or trough the email address