Wednesday, 30 August 2017

sample drone yaml example


    Drone is a CI/CD tool which is integrated with git repo and executes automatically for testing the pipeline from git repo when an update/push happened from git.

 * It has multiple sections and each one execute one after another inside the drone.
In below example, "clone", "build", "env_set",  "publish" are multiple sections. Inside each section the require parameters are there which works individually for that section only.

 * save as ".drone.yaml" in the repo and add to git repo.

 * Allow the git to execute from drone end.

--------------------------------------  xxxxxxxxxx   --------------------------------------------------------------
pipeline: # (started from here for pipeline)

  git_clone_section_here:  # (section for clone the git to drone, any name is fine)
    image: plugins/git
    recursive: true
    tags: true
    submodule-update-remote: true

  build:  # (section for build the image)
      image: "plugins/docker:latest"
      dry_run: true
      repo: <docker hub url>
      registry: <docker reg, name>
      dockerfile: .dockerfile
      when:
        branch:
          exclude: master


 env_set: #
      image: "<image name>"
      commands:
          - env
      when:
        event: push
        branch:
          exclude: master  # exclude the master branch



publish: (section for publish the image)
      image: "plugins/docker:latest"
      repo: <docker hub url>
      registry: <docker reg. url>
      docker.registry: <docker reg. url>
      dockerfile: .dockerfile
      environment:
      - PLUGIN_ENV_FILE=/drone/docker-env
      when:
        event: tag # drone execute when git tag / git version chages

No comments:

Prasanta Kumar Behera. Mob- 8147470101