Skip to main content

Run a Drone Plugin in CI

A Drone Plugin is a Docker container that performs a predefined task. Plugins are essentially templated scripts that can be written in any programming language. The Drone community maintains an extensive library of plugins for specific CI workflows. You can customize and extend your build processes using existing plugins or write your own.

This topic describes how to set up and run Drone Plugins in your CI pipelines. You can also use GitHub Action plugin steps and Bitrise plugin steps to run GitHub Actions and Bitrise Integrations in your CI pipelines.

Before You Begin

To install and run a plugin, you need the following:

Workflow Description

The following steps describe the high-level workflow:

  1. Go to the Pipeline and open the Build step where you want to run the plugin.
  2. In the Execution tab, click Add step and select Plugin.
  3. Enter the following:
    1. Name: A unique, descriptive name.
    2. Container Registry: A Connector to the image registry (such as Docker Hub) of the plugin image.
    3. Image: The full image name, such asdockerhubusername/my-plugin:2.3.1. The Step uses the latest image if you don't specify a tag.
    4. Under Optional Configuration > Settings, add any other settings that are required as specified in the docs for the specific plugin.
  4. Click Apply Changes to apply your Stage settings, then Save to save the updated Pipeline
  5. Run the updated Pipeline and check the log output to verify that the Plugin Step works as intended.

Simple Example: Download a File

This example describes how to run the Drone Downloads plugin, which downloads an archive to your build infrastructure. You can use the following workflow to implement any plugin.

  1. Go to the Drone Plugins Marketplace and read the description for the specific plugin. The description should indicate the plugin image and the required settings.

    The Download plugin doc shows the image to use (plugins/download) and the settings that the plugin supports: source, destination, username, password, and so on.

  2. Go to the Build Stage in a CI Pipeline. In the Execute tab, add a Plugin step.

  3. Configure the Step as follows.

    • Name: A unique, descriptive name.
    • Container Registry: A Connector to Docker Hub.
    • Image: The plugin image --in this case, plugins/download
    • Under Optional Configuration, add the following settings:
      • source = The artifact to download.
      • destination = Save the downloaded artifact to this file.
      • username = A valid username for the Git provider.
      • password = The ID of the text secret that contains the Git provider password, using the convention described here. For example: <+secrets.getValue("mygithubpersonalaccesstoken")>

  4. Click Apply Changes to apply your stage settings, then Save to save the updated Pipeline

  5. Run the updated Pipeline and check the log output to verify that the Plugin Step works as intended.

Convert Drone Plugin YAML to Harness CI YAML

You can use YAML examples in the Drone Plugins Marketplace to configure a Plugin step in Harness CI. While the formats are slightly different, it is fairly simple to translate Drone Plugin definitions to Harness CI YAML.

Listed and nested settings

To list-formatted settings from Drone Plugin YAML to Harness CI YAML, merge them with comma separation.

Settings:
tags:
- latest
- '1.0.1'
- '1.0'

For nested settings, maintain key-value pair definitions, as shown in the following Harness CI YAML example:

settings:
mynestedsetting:
nextlevel:
varname: 100
mylistsetting:
- itemone
- itemtwo

It's often easier to define complex settings in the Pipeline Studio's YAML editor, rather than the Visual editor. The settings in the above example would be defined in the Visual editor as shown in the following screenshot.

Text Secrets

The following snippets illustrate the different ways that Drone and Harness CI handle text secrets.

Note that the CI definition includes a few additional fields and that some fields use different formats.

steps:
- name: download
image: plugins/download
settings:
username:
from_secret: username
password:
from_secret: password
source: https://github.com/drone/drone-cli/releases/download/v0.8.5/drone_linux_amd64.tar.gz

More examples

You can see additional examples in the GitHub Actions Support in Harness CI blog post.

See also