Integrations

Integrating with Drone CI

Drone is a Continuous Integration platform that allows automation of build, test, and release workflows using a powerful, cloud-native pipeline engine.

API Key Configuration

You need to add your Cloudsmith API Key within Drone CI. We recommend storing your Cloudsmith API Key as a per-repository or per-organization secret in the Drone Server and then injecting the CLOUDSMITH_API_KEY environment variable into your build jobs like:

yaml
environment:
  CLOUDSMITH_API_KEY:
    from_secret: CLOUDSMITH_API_KEY

Alternatively, you can authenticate without a stored API key by using OpenID Connect (OIDC). Set the CLOUDSMITH_OIDC_TOKEN, CLOUDSMITH_ORG, and CLOUDSMITH_SERVICE_SLUG environment variables and the CLI automatically exchanges the OIDC token for a short-lived Cloudsmith token. See OpenID Connect for provider setup.

Examples

In the following examples:

IdentifierDescription
WORKSPACEYour Cloudsmith Workspace slug
REPOSITORYYour Cloudsmith Repository name (also called "slug")
FORMATThe format of the package, for example, "deb", "maven", or "npm"
PACKAGE_FILEThe filename of the package

Build step example

To push an artifact from a build step, you just need to add the commands to install the standalone Cloudsmith CLI with the install script and then use the cloudsmith push command. The install script prints the installation result as key=value lines; the commands below parse bin_dir from that output and add it to PATH:

yaml
steps:
  - name: Push package
    image: ubuntu:24.04
    environment:
      CLOUDSMITH_API_KEY:
        from_secret: CLOUDSMITH_API_KEY
    commands:
      - apt-get update && apt-get install -y ca-certificates curl
      - install_output="$(curl -fsSL https://install.cloudsmith.com/raw/versions/latest/cli.sh | sh -s -- --version 1.20.1)"
      - bin_dir="$(printf '%s\n' "$install_output" | sed -n 's/^bin_dir=//p')"
      - export PATH="$bin_dir:$PATH"
      - cloudsmith push FORMAT WORKSPACE/REPOSITORY PACKAGE_FILE

Docker pipeline example

Drone supports different types of pipelines, each optimized for different use cases and runtime environments.

For example, you can use a Docker pipeline with your own Docker image that includes the Cloudsmith CLI, negating the need to install the CLI in a Build Step. The following example configuration specifies a Docker image from a Cloudsmith repository:

yaml
steps:
- name: Build and Push Package
  image: docker.cloudsmith.io/WORKSPACE/REPOSITORY/IMAGE_NAME:latest
  environment:
    CLOUDSMITH_API_KEY:
      from_secret: CLOUDSMITH_API_KEY
  commands:
    - .......
    - .......
    - cloudsmith push FORMAT WORKSPACE/REPOSITORY PACKAGE_FILENAME
image_pull_secrets:
 - dockerconfigjson

As the Docker image used for the pipeline in this example is hosted in a private Cloudsmith repository, you need to authenticate to the repository to pull the image for use. You can add the authentication credentials as a per-repository or per-organization secret in Drone CI. You can obtain these credentials from your ~/.docker/.config.json file after you do a normal docker login to your Cloudsmith repository

You then use image_pull_secrets, with the name of the secrets file you created in Drone CI to enable your pipeline to authenticate to your Cloudsmith repository.

Note

The push command will vary with the package format, an example of the push command for a debian package would look like: cloudsmith push deb my-org/my-repo/ubuntu/xenial foo-1.0.deb. Please see the Cloudsmith CLI for full details of the push command for other formats and additional help.