Question

Push an image to DigitalOcean through Bitbucket pipelines

Posted December 29, 2020 3k views
DeploymentDigitalOcean API and CLI (doctl)DigitalOcean Container Registry (DOCR)

I try to push an image to DigitalOcean through bitbucket pipelines but I have a problem with doctl

image: atlassian/default-image:2

pipelines:
  branches:
    stage:
      - step:
          name: Deploy to registry
          script:
            - echo "deploy to registry"
            - curl -sL https://github.com/digitalocean/doctl/releases/download/v1.54.0/doctl-1.54.0-linux-amd64.tar.gz | tar -xzv
            - mv ./doctl /usr/local/bin
            - doctl auth init -t 57bab70792ca2049e2644bebbb5234a9sdas9d7as897da9s7d98as7d9aas8d99 &&
            - doctl account get
            - doctl registry login --trace. 
# THIS HERE DOES NOT WORK I GET AN ERROR ON PIPELINES 
#Error: GET https://api.digitalocean.com/v2/registry/docker-credentials?read_write=true: 403 you do not have access for the attempted action
      - step:
          name: Deploy to droplet
          script:
            - echo "deploy on stage"

Has someone an idea how to fix this and then push the Image to DO Registry

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

@SmallAquaFish, hi, did you manage to get this working?

  •   - step:
          name: Deploy to registry
          services:
            - docker
          script:
            - echo "deploy to registry"
            - export APP_NAME=app
            - export IMAGE_NAME=registry.digitalocean.com/myregistry/$APP_NAME:$BITBUCKET_TAG
            - export REGISTRY_TOKEN=d4be05e731a9s8d78asd7982ee299999999997ffa6523b106cb7e6bec794200614d3947d3348
            - docker build . -t $IMAGE_NAME -f build/Dockerfile
            - curl -sL https://github.com/digitalocean/doctl/releases/download/v1.54.0/doctl-1.54.0-linux-amd64.tar.gz | tar -xzv
            - mv ./doctl /usr/local/bin
            - doctl auth init -t $REGISTRY_TOKEN
            - docker login -u $REGISTRY_TOKEN -p $REGISTRY_TOKEN registry.digitalocean.com
            - docker push $IMAGE_NAME