• Stars
    star
    133
  • Rank 272,549 (Top 6 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 5 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Drone conversion extension to include/exclude pipelines and pipeline steps based on paths changed

Drone Conversion Extension: Paths Changed | Build Status Docker Pulls

A Drone conversion extension to include/exclude pipelines and steps based on paths changed.

Please note this project requires Drone server version 1.4 or higher.

Installation

Github Cloud

  1. Create a github token via https://github.com/settings/tokens with the scope ofrepo (see issue 13 for background).

  2. Create a shared secret:

$ openssl rand -hex 16
bea26a2221fd8090ea38720fc445eca6
  1. Download and run the plugin:
$ docker run -d \
  --publish=3000:3000 \
  --env=DRONE_DEBUG=true \
  --env=DRONE_SECRET=bea26a2221fd8090ea38720fc445eca6 \
  --env=TOKEN=9e6eij3ckzvpe9mrhnqcis6zf8dhopmm46e3pi96 \
  --env=PROVIDER=github \
  --restart=always \
  --name=converter meltwater/drone-convert-pathschanged

If you wish to use an enviroment file you can pass it when starting the container :

$ docker run -d \
...
  --name=converter meltwater/drone-convert-pathschanged --envfile drone.env
  1. Update your Drone server configuration to include the plugin address and the shared secret.
DRONE_CONVERT_PLUGIN_ENDPOINT=http://1.2.3.4:3000
DRONE_CONVERT_PLUGIN_SECRET=bea26a2221fd8090ea38720fc445eca6

Github Server

  1. Create a github token via https://your-github-server-address/settings/token with the scope of repo

  2. Create a shares secret:

$ openssl rand -hex 16
bea26a2221fd8090ea38720fc445eca6
  1. Download ran run the plugin:
$ docker run -d \
  --publish=3000:3000 \
  --env=DRONE_DEBUG=true \
  --env=DRONE_SECRET=bea26a2221fd8090ea38720fc445eca6 \
  --env=TOKEN=9e6eij3ckzvpe9mrhnqcis6zf8dhopmm46e3pi96 \
  --env=PROVIDER=github \
  --env=GITHUB_SERVER=https://your-github-server-address
  --restart=always \
  --name=converter meltwater/drone-convert-pathschanged
  1. Update your Drone server configuration to include the plugin address and the shared secret.
DRONE_CONVERT_PLUGIN_ENDPOINT=http://1.2.3.4:3000
DRONE_CONVERT_PLUGIN_SECRET=bea26a2221fd8090ea38720fc445eca6

Bitbucket Cloud

  1. Create an "App password" via https://bitbucket.org/account/settings/app-passwords and select only "Read" under "Repositories"

  2. Create a shared secret:

$ openssl rand -hex 16
bea26a2221fd8090ea38720fc445eca6
  1. Download and run the plugin:
$ docker run -d \
  --publish=3000:3000 \
  --env=DRONE_DEBUG=true \
  --env=DRONE_SECRET=bea26a2221fd8090ea38720fc445eca6 \
  --env=BITBUCKET_USER=youruser \
  --env=BITBUCKET_PASSWORD='yourpassword' \
  --env=PROVIDER=bitbucket \
  --restart=always \
  --name=converter meltwater/drone-convert-pathschanged
  1. Update your Drone server configuration to include the plugin address and the shared secret.
DRONE_CONVERT_PLUGIN_ENDPOINT=http://1.2.3.4:3000
DRONE_CONVERT_PLUGIN_SECRET=bea26a2221fd8090ea38720fc445eca6

Stash (Bitbucket Server)

  1. Create a Stash access token via https://your-bitbucket-address/plugins/servlet/access-tokens/manage with read-only rights

  2. Create a shared secret:

$ openssl rand -hex 16
bea26a2221fd8090ea38720fc445eca6
  1. Download and run the plugin:
$ docker run -d \
  --publish=3000:3000 \
  --env=DRONE_DEBUG=true \
  --env=DRONE_SECRET=bea26a2221fd8090ea38720fc445eca6 \
  --env=TOKEN=9e6eij3ckzvpe9mrhnqcis6zf8dhopmm46e3pi96 \
  --env=PROVIDER=bitbucket-server \
  --env=STASH_SERVER=https://your-bitbucket-server-address
  --restart=always \
  --name=converter meltwater/drone-convert-pathschanged
  1. Update your Drone server configuration to include the plugin address and the shared secret.
DRONE_CONVERT_PLUGIN_ENDPOINT=http://1.2.3.4:3000
DRONE_CONVERT_PLUGIN_SECRET=bea26a2221fd8090ea38720fc445eca6

Gitee Cloud

  1. Create a gitee token via https://gitee.com/personal_access_tokens with the scope ofrepo (see issue 13 for background).

  2. Create a shared secret:

$ openssl rand -hex 16
bea26a2221fd8090ea38720fc445eca6
  1. Download and run the plugin:
$   docker run -d \
  --publish=3000:3000 \
  --env=DRONE_DEBUG=true \
  --env=DRONE_SECRET=bea26a2221fd8090ea38720fc445eca6 \
  --env=TOKEN=b4af6fc778a7aba5f2a133d155f5b4a9cbe7becb255557e67597a4967eb50a88 \
  --env=PROVIDER=gitee \
  --restart=always \
  --name=converter meltwater/drone-convert-pathschanged
  1. Update your Drone server configuration to include the plugin address and the shared secret.
DRONE_CONVERT_PLUGIN_ENDPOINT=http://1.2.3.4:3000
DRONE_CONVERT_PLUGIN_SECRET=bea26a2221fd8090ea38720fc445eca6

Examples

This extension uses doublestar for matching paths changed in your commit range, refer to their documentation for all supported patterns.

include

Only run a pipeline when README.md is changed:

---
kind: pipeline
name: readme

trigger:
  paths:
    include:
    - README.md

steps:
- name: message
  image: busybox
  commands:
  - echo "README.md was changed”

Only run a pipeline step when README.md is changed:

---
kind: pipeline
name: readme

steps:
- name: message
  image: busybox
  commands:
  - echo "README.md was changed”
  when:
    paths:
      include:
      - README.md

Same as above, but with an implicit include:

---
kind: pipeline
name: readme

steps:
- name: message
  image: busybox
  commands:
  - echo "README.md was changed”
  when:
    paths:
    - README.md

include and exclude

Run a pipeline step when .yml files are changed in the root, except for .drone.yml:

---
kind: pipeline
name: yaml

steps:
- name: message
  image: busybox
  commands:
  - echo "A .yml file in the root of the repo other than .drone.yml was changed"
  when:
    paths:
      include:
      - "*.yml"
      exclude:
      - .drone.yml

depends_on

When using depends_on in a pipeline step, ensure the paths rules match, otherwise your steps may run out of order.

Only run two steps when README.md is changed, one after the other:

---
kind: pipeline
name: depends_on

steps:
- name: message
  image: busybox
  commands:
  - echo "README.md was changed”
  when:
    paths:
      include:
      - README.md

- name: depends_on_message
  depends_on:
  - message
  image: busybox
  commands:
  - echo "This step runs after the message step"
  when:
    paths:
      include:
      - README.md

Changesets

The changeset is generated by comparing the list of files changed between the commit before the patch is applied and the commit after the patch is applied. As a result, the changeset for a commit may be different depending on which type of event triggered the build.

For example, the push and tag events may generate a changeset against the previous commit, where as the pull_request event may generate a changeset against the source branch. For more specifics on how before and after are set, review the webhook parser.

Known issues

Empty commits

Be careful when making empty commits with git commit --allow-empty. When an empty commit is made, no files have changed, so this plugin will return the unmodified .drone.yml back to the drone server process.

This can lead to potentially unexpected behavior, since any include or exclude rules will effectively be ignored.

YAML anchors

There is a problem in the YAML library where ordering matters during unmarshaling, see #18

This syntax will fail:

anchor: &anchor
  image: busybox
  settings:
    foo: bar

- name: test
  <<: *anchor
  when:
    event: push
    branch: master

But this will succeed:

anchor: &anchor
  image: busybox
  settings:
    foo: bar

- <<: *anchor 
  name: test
  when:
    event: push
    branch: master

Contributing

Please read CONTRIBUTING.md to understand how to submit pull requests to us, and also see our code of conduct.

Protected Repos

When this plugin is used in conjunction with protected repos, signature validation will frequently fail.

This occurs due to Drone's order of operations, in that the Drone file's signature is checked after the this plugin has rewritten sections based on the paths-changed triggers, resulting in a different signature for the file.

More Repositories

1

served

A C++11 RESTful web server library
C++
709
star
2

docker-cleanup

DEPRECATED Automatic Docker image, container and volume cleanup
Shell
586
star
3

drone-cache

A Drone plugin for caching current workspace files between builds to reduce your build times
Go
335
star
4

gen_rmq

Elixir AMQP consumer and publisher behaviours
Elixir
183
star
5

secretary

DEPRECATED Secrets management for dynamic environments
Go
94
star
6

terraform-aws-asg-dns-handler

Terraform module for dynamically setting hostnames following a pattern on instances in AWS Auto Scaling Groups
Python
75
star
7

rabbitio

RabbitIO is used to move data in and out of RabbitMQ
Go
70
star
8

elasticsearch-batch-percolator

(deprecated) High performance Elasticsearch percolator
Java
48
star
9

lighter

DEPRECATED Marathon deployment automation tool
Python
43
star
10

awsudo

A simple utility for executing cli commands with an assumed role.
JavaScript
41
star
11

docker-mesos

Mesos, Marathon and Chronos using Docker Compose
Shell
39
star
12

jugri

The JUpyter-GRemlin Interface
Python
35
star
13

rxrabbit

RabbitMQ Java client built on RxJava
Java
33
star
14

ex_lsh

A configurable implementation of locality-sensitive hashing in Elixir
Elixir
25
star
15

proxymatic

DEPRECATED Marathon service discovery proxy
Python
24
star
16

quitsies

A persisted drop-in replacement for Memcached, respecting the rules of quitsies.
C++
16
star
17

api-gateway-demo

Nginx application showcasing how to do lightweight tests with ruby rspec
Ruby
15
star
18

kotlin-compose

Docker-compose wrapper for the JVM
Kotlin
12
star
19

rabbit-puppy

Configures RabbitMQ server based on YAML configuration
Kotlin
7
star
20

docker-elasticsearch-aws

Elasticsearch Docker image with the Amazon EC2 plugin
7
star
21

MeltwaterEng-public-presentations

List of public talks by Meltwater Engineering: meetup presentations, recorded conference talks, slides.
7
star
22

tau

Functional time and date JavaScript library.
JavaScript
6
star
23

puppet-marathon

Puppet Module for Mesos Marathon
Ruby
6
star
24

puppet-cobbler

Fork of https://bitbucket.org/jsosic/puppet-cobbler
HTML
5
star
25

puppet-incron

Puppet module to provide an incron resource type
Ruby
4
star
26

sparkline

ANSI Sparklines for Elixir
Elixir
4
star
27

supervisor_health

Elixir
4
star
28

meltwater-elasticsearch-queries

Java
3
star
29

phi

Functional tools for JavaScript inspired by Ramda and Ramda Adjunct.
JavaScript
3
star
30

confex_config_provider

Confex runtime configuration provider for Distillery
Elixir
3
star
31

vagrant-coreos

Vagrant infrastructure for CoreOS on Amazon AWS
HTML
3
star
32

underthehood-blog-tests-examples

Examples for blog post "Using Selenium-Server on Docker to run your Browser Tests"
Ruby
3
star
33

mlabs-health

Health monitor for Node.js microservices.
JavaScript
3
star
34

makenew-koa-service

Bootstrap a new Node.js Koa microservice in five minutes or less.
Shell
2
star
35

esi-include-webpack-plugin

Webpack 4 plugin to inject an esi comment for prod OR fetch and do the injection in dev
JavaScript
2
star
36

mlabs-aws

Convenient wrappers around the AWS SDK to keep code DRY.
JavaScript
2
star
37

threaded-logstasher

DEPRECATED Threaded logstash handler and formatter in Python.
Python
2
star
38

makenew-node-lib

Bootstrap a new Node.js npm package in five minutes or less.
Shell
2
star
39

docker-foundation-terraform

Repo to use when building terraforming docker image
2
star
40

node-examplr

Example runner for Node.js packages.
JavaScript
2
star
41

mlabs-graphql

Node.js GraphQL client and server toolkit.
JavaScript
2
star
42

docker-aws-cli

Custom Docker build of the AWS CLI
Dockerfile
1
star
43

the-orchard

A CLI tool to generate the markup for including web dependencies
JavaScript
1
star
44

puppet-erlang

puppet module to install erlang from source
Puppet
1
star
45

puppet-python

Installation of python from source via puppet
Puppet
1
star
46

mlabs-http

Node.js HTTP client wrapper around Got
JavaScript
1
star
47

puppet-monit

HTML
1
star
48

puppet-newrelic_agent

Puppet Module for Installing & Managing the various NewRelic server monitoring agents
Puppet
1
star
49

docker-nginx-http-https-reverse-proxy

Nginx HTTP server which proxies an external SSL host
Dockerfile
1
star
50

pagerduty-campfire

Polls Pagerduty for new stuff, posts it to Campfire
1
star
51

meltwater-ruby

(deprecated) Ruby Client for the Meltwater API
Ruby
1
star
52

terraform-provider-meltwater

A Terraform provider for Meltwater based on the persistent/infrastructure parts of the Meltwater API. Such as setting up webhooks and recurring exports.
Go
1
star
53

puppet-es

Puppet module for Elastic Search as a Defined Type
HTML
1
star
54

mlabs-logger

Structured logging for Node.js services.
JavaScript
1
star
55

mlabs-koa

Koa middleware suite and server bootstrapper.
JavaScript
1
star
56

docker-awscli

Docker image of Amazon AWS Command Line Interface
Shell
1
star
57

meltwater-killercoda

Meltwater Engineering's Public / Shared Training Center
Shell
1
star
58

meltwater-php

(deprecated) PHP Client for the Meltwater API
PHP
1
star
59

.github

Meltwater's community health files
1
star