Bitbucket Pipelines revisited: Alpine

I wanted to be able to use always the latest version of hugo. However, the jq version provided by the default image of bitbucker is rather old.

Therefore, I used alpine linux image with allows much more recent version of the tools.

In order to use bitbucket pipelines, it was really easy. Just create a file bitbucket-pipelines.yml:

image: alpine:latest

    - step:
          - apk update
          - apk add jq wget rsync ca-certificates openssh-client
          - wget -O - | jq -r '.assets[] | select(.name | index("Linux-64bit.tar.gz")) | .browser_download_url' | wget -i -
          - tar xzf hugo*.tar.gz
          - chmod a+x hugo
          - ./hugo -b "" -d public
          - rsync -avz --exclude "*.htaccess" --exclude ".well-known" --delete public/

This is slightly slower than using the default image, but it will always pull the latest hugo. Enjoy!

Alternatively, you can use the following jq command that works with version 1.3 (provided by bitbucket default image):

jq -r ".assets[] | select(.name | contains(\"Linux-64bit.deb\")) | .browser_download_url"