aboutsummaryrefslogtreecommitdiff

Yet Another Docker Plugin config builder

Yet Another Docker Plugin (YADP) is extremely hard to manage, when running multiple slaves with multiple images. Due to the way Jenkins displays the configuration page. YADP provides a groovy script which builds a JSON array to populate the configuration in Jenkins.

This script uses YAML and jinja2 to generate a java jsonarray to build the configuration, using a !include constructor in the YAML file, allowing the ability to template up docker_images, since many of our slaves run the same image, it lessens repetition.

Usage

hosts.yml

List your jenkin_slaves here

- host1:
  cloud_name: host1.example.org
  docker-url: tcp://0.0.0.0:2375
  docker_templates: !include external_template_file.yml

- host2:
  cloud_name: host2
  docker-url: tcp://0.0.0.1:2375
  docker_templates:
    - xenial-amd64:
      docker_image_name: 'ubuntu:latest'
      max_instances: '1'
      labels: 'docker-ubuntu'

- host3
  cloud_name: host3.example.org
  docker-url: tcp://0.0.0.0:2375
  docker_templates:
    !include [external_template_file.yml, external_template_file_2.yml]

Limitations

Due to the nature of YAML and populating the Java JSONARRAY, its important that yaml is phased correctly.

Most of the limitations surround docker_templates.

A list of limitations and pending improvements.

  1. Do not mix !include and templates under docker_templates.

Example of broken approach:

  • host1: cloud_name: host1.example.org docker-url: tcp://0.0.0.0:2375 docker_templates: !include external_template_file.yml
  • xenial-amd64: docker_image_name: 'ubuntu:latest' max_instances: '1' labels: 'docker-ubuntu'

  • Do not add spaces under the image cloud_name, the must fall inline with the image name

Example of broken approach: - xenial-amd64: docker_image_name: 'ubuntu:latest' max_instances: '1' labels: 'docker-ubuntu'

  1. Docker labels could be "host" specific. If you are including a template file, the template has no link to the host, so its not possible to do "host based labels". Instead just create another template file with custom settings and include that file.