No worries about Magento 1 End-of-Life - all our Magento 1 Extensions will be supported further and actively developed!


Notes of a Magento Developer's Life

Hugo Deployments with Bitbucket Pipelines

Bitbucket has a great feature called Bitbucket Pipelines with that you are able to do tasks automatically after code has been pushed to the repository. This workflow can also be used for Hugo deployments with Bitbucket Pipelines.

Typical tasks for pipelines from my customer projects include e.g.

  • deployments
  • run phpunit test suite
  • make code syntax checks, e.g. run phpstan, code sniffer, etc.
  • generate anonymized dumps for staging environments

Specifically for Hugo projects like this blog I use it to deploy the code automatically to the testing or live servers. The feature is very powerful because you can use any Docker image you like to run the commands. You can either use one of the existing Atlassian images or public images from the Docker registry or create your own one and publish it.

To use pipelines you simply have to activate the Bitbucket Pipelines feature in the configuration settings of the repository and add a file called bitbucket-pipelines.yml to your repository code.
Here is a sample content of the file for deploying a Hugo project when pushing code to master branch. The pipeline has 2 steps for build/test and deployment. The result of the first step is a file called that is then deployed to your server.

image: node:latest

      - step:
          name: Build and Test
            - apt-get update -y && apt-get -y install wget git zip
            - wget
            - dpkg -i hugo*.deb
            - git submodule update --init --remote
            - hugo
            - (cd public && zip -r ../ .)
      - step:
          name: Deploy to Production
          deployment: production
            - pipe: atlassian/scp-deploy:0.3.12
                USER: $SSH_USER
                SERVER: $SSH_HOST
                LOCAL_PATH: ''
            - pipe: atlassian/ssh-run:0.2.6
                SSH_USER: $SSH_USER
                SERVER: $SSH_HOST
                COMMAND: './'

For this pipeline to work you also have to generate and add the SSH key to the server where you want to deploy to in the pipeline settings in the repository. Additionally you have to add the variables $SSH_USER, $SSH_HOST and $SSH_REMOTE_PATH to the environment “Production”.
Also this pipeline assumes that you have a script on your server that does the unzipping of the release artefact.

To test this pipeline simply push the created bitbucket-pipelines.yml file to the remote Bitbucket repository. Then go to the repository in the browser and under “Pipelines” you will see the current status of the pipeline as well as any errors: Bitbucket Pipelines