1

I have a (.drone.yml) test file from which i want to build a docker image. According to the documentations i have to build it using drone .

I tried this tutorial ( https://www.digitalocean.com/community/tutorials/how-to-perform-continuous-integration-testing-with-drone-io-on-coreos-and-docker ) and several other tutorials but i failed .

can anyone show me please a simple way to build .drone.yml ! Thank you

user3034057
  • 19
  • 1
  • 3
  • 1
    What did you try and how did you fail ? – Marged Aug 07 '16 at 12:45
  • I tried the tutorial i mentioned above , the error i got is ( Service timeout ) next to the red triangle pointing to the webhook after i made a commit to my github repository . – user3034057 Aug 07 '16 at 14:41
  • I would recommend the official documentation for using and installing drone. The digital ocean documentation was great, but is now outdated and there is nobody at Digital Ocean going back through to update stale documentation. – Brad Rydzewski Aug 20 '16 at 23:59

1 Answers1

6

Note that this answer applies to drone version 0.5

You can use the Docker plugin to build and publish a Docker image at the successful completion of your build. You add the Docker plugin as a step in your build pipeline section of the .drone.yml file:

pipeline:
  build:
    image: golang
    commands:
      - go build
      - go test
  publish:
    image: plugins/docker
    repo: foo/bar

In many cases you will want to limit execution of the this step to certain branches. This can be done by adding runtime conditions:

  publish:
    image: plugins/docker
    repo: foo/bar
    when:
      branch: master

You will need to provide drone with credentials to your Docker registry in order for drone to publish. These credentials can be declared directly in the yaml file, although storing these values in plain text in the yaml is generally not recommended:

  publish:
    image: plugins/docker
    repo: foo/bar
    username: johnsmith
    password: pa55word
    when:
      branch: master

You can alternatively provide your credentials using the built-in secret store. Secrets can be added to the secret store on a per-repository basis using the Drone command line utility:

  export DRONE_SERVER=http://drone.server.address.com
  export DRONE_TOKEN=...

  drone secret add \
    octocat/hello-world DOCKER_USERNAME johnsmith

  drone secret add \
    octocat/hello-world DOCKER_PASSWORD pa55word

  drone sign octocat/hello-world

Secrets are then interpolated in your yaml at rutnime:

  publish:
    image: plugins/docker
    repo: foo/bar
    username: ${DOCKER_USERNAME}
    password: ${DOCKER_PASSWORD}
    when:
      branch: master
Brad Rydzewski
  • 2,523
  • 14
  • 18